What are the potential security risks when using filter_input in PHP for search functionality?

When using filter_input in PHP for search functionality, one potential security risk is that it may not properly sanitize user input, leaving the application vulnerable to SQL injection attacks. To mitigate this risk, it is important to use proper filtering and validation functions to ensure that user input is sanitized before using it in database queries.

$searchTerm = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_STRING);
if ($searchTerm) {
    // Use $searchTerm in your database query after proper sanitization
} else {
    // Handle case where search term is not provided
}