What are potential risks of not validating user inputs in PHP applications?

Not validating user inputs in PHP applications can lead to security vulnerabilities such as SQL injection, cross-site scripting (XSS), and other forms of attacks. To mitigate these risks, it is important to validate and sanitize all user inputs before using them in your application.

// Example of validating user input in PHP using filter_var function
$input = $_POST['input'];

// Validate input as an email address
if(filter_var($input, FILTER_VALIDATE_EMAIL)) {
    // Input is a valid email address
} else {
    // Input is not a valid email address
}