Are there any security vulnerabilities present in the current PHP registration script?

The current PHP registration script is vulnerable to SQL injection attacks due to the use of unsanitized user input in SQL queries. To solve this issue, we need to use prepared statements with parameterized queries to prevent SQL injection attacks.

// Fix for SQL injection vulnerability in registration script

// Establish database connection
$pdo = new PDO("mysql:host=localhost;dbname=mydatabase", "username", "password");

// Prepare SQL statement with placeholders for user input
$stmt = $pdo->prepare("INSERT INTO users (username, email, password) VALUES (:username, :email, :password)");

// Bind parameters to placeholders
$stmt->bindParam(':username', $_POST['username']);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':password', $_POST['password']);

// Execute the prepared statement
$stmt->execute();