What potential security vulnerability should be considered when inserting values into a database using user input in PHP?

When inserting values into a database using user input in PHP, the potential security vulnerability to consider is SQL injection. This occurs when a user input is not properly sanitized and an attacker is able to manipulate the SQL query to execute malicious commands. To prevent SQL injection, it is important to use prepared statements or parameterized queries to sanitize user input before inserting it into the database.

// Using prepared statements to prevent SQL injection
$pdo = new PDO("mysql:host=localhost;dbname=mydatabase", "username", "password");

// User input
$userInput = $_POST['user_input'];

// Prepare the SQL statement
$stmt = $pdo->prepare("INSERT INTO mytable (column_name) VALUES (:user_input)");

// Bind the parameter
$stmt->bindParam(':user_input', $userInput);

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