What are the potential security risks of not properly handling SQL injections in PHP code?

SQL injections in PHP code can lead to unauthorized access to databases, data loss, data manipulation, and potentially complete control of the server. To prevent SQL injections, developers should use prepared statements and parameterized queries to sanitize user input before executing SQL queries.

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