What potential security risks should be considered when adding additional search parameters to a PHP script?

When adding additional search parameters to a PHP script, it is important to consider potential security risks such as SQL injection attacks. To prevent this, it is recommended to sanitize and validate user input before using it in SQL queries. This can be done by using prepared statements or parameterized queries to safely handle user input.

// Example of using prepared statements to prevent SQL injection

$searchTerm = $_GET['search'];

// Prepare a SQL statement
$stmt = $pdo->prepare("SELECT * FROM table WHERE column = :searchTerm");

// Bind the search term parameter
$stmt->bindParam(':searchTerm', $searchTerm);

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

// Fetch the results
$results = $stmt->fetchAll();