What security vulnerability is mentioned in one of the forum responses regarding SQL injection?
SQL injection is a security vulnerability where an attacker can manipulate SQL queries by injecting malicious code into input fields of a web application. This can lead to unauthorized access to the database, data leakage, and other malicious activities. To prevent SQL injection, developers should use parameterized queries or prepared statements to sanitize user input before executing SQL queries.
// Using parameterized queries 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();