What are common security vulnerabilities in PHP scripts that could lead to data disappearing from a database?

One common security vulnerability in PHP scripts that could lead to data disappearing from a database is SQL injection. This occurs when user input is not properly sanitized before being used in SQL queries, allowing malicious users to manipulate the database. To prevent SQL injection, always use prepared statements or parameterized queries when interacting with the database.

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