What are some common pitfalls to avoid when using PHP for user registration and internal page features like photo galleries, forums, and file upload/download areas?

One common pitfall to avoid is not properly sanitizing user input, which can lead to security vulnerabilities such as SQL injection or cross-site scripting attacks. To prevent this, always use prepared statements when interacting with a database and validate and sanitize all user input before using it in your PHP code.

// Example of using prepared statements to prevent SQL injection
$stmt = $pdo->prepare('SELECT * FROM users WHERE username = :username');
$stmt->bindParam(':username', $username);
$stmt->execute();
```

```php
// Example of validating and sanitizing user input
$username = filter_var($_POST['username'], FILTER_SANITIZE_STRING);
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);