What are common security vulnerabilities in PHP scripts for user registration and login forms?

One common security vulnerability in PHP scripts for user registration and login forms is SQL injection. To prevent this, use prepared statements with parameterized queries to sanitize user input before executing SQL queries.

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