PHP Beginner's Introduction to Email Injection
PHP Prevent E-mail Injection
The best way to prevent e-mail injection is to validate the input.
The following code is similar to the one in the previous chapter, but here we have added an input validation program to detect the email field in the form:
php中文网(php.cn) Email:
Subject:
Message:
"; } ?>
Note:
is above In the code, we use PHP filter to validate the input:
FILTER_SANITIZE_EMAIL filter removes illegal characters of email from the string
FILTER_VALIDATE_EMAIL filter validates the value of email address
You can read more about filters in our PHP Filter.