What are some common pitfalls to avoid when validating email addresses in PHP forms?

One common pitfall to avoid when validating email addresses in PHP forms is not using a robust validation method. A simple check for the presence of an "@" symbol is not enough to ensure a valid email address. To properly validate email addresses, you should use PHP's built-in filter_var function with the FILTER_VALIDATE_EMAIL filter.

$email = $_POST['email'];

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "Invalid email address";
} else {
    echo "Email address is valid";
}