What are the potential security risks of using user inputs without filtering or validation in PHP?

Using user inputs without filtering or validation in PHP can lead to security risks such as SQL injection, cross-site scripting (XSS), and other forms of attacks. To mitigate these risks, it is essential to sanitize and validate user inputs before using them in your PHP code.

// Example of sanitizing user input using filter_var
$userInput = $_POST['user_input'];
$sanitizedInput = filter_var($userInput, FILTER_SANITIZE_STRING);