Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Sanitize and validate an email address
SUBMITTED BY:
henry1874w
DATE:
June 21, 2017, 11:47 p.m.
FORMAT:
Text only
SIZE:
390 Bytes
Raw
Download
Tweet
HITS:
401
Go to comments
Report
<!DOCTYPE html>
<html>
<body>
<?php
$email = "john.doe@example.com";
// Remove all illegal characters from email
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
// Validate e-mail
if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
echo("$email is a valid email address");
} else {
echo("$email is not a valid email address");
}
?>
</body>
</html>
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus