What are the potential security risks of using user-input data directly in email headers in PHP?
Using user-input data directly in email headers in PHP can lead to security risks such as email header injection attacks. To prevent this, it is important to sanitize and validate the user-input data before using it in email headers. This can be done by using PHP's `filter_var()` function with the `FILTER_SANITIZE_EMAIL` filter to ensure that the input is a valid email address.
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";