PHP Email Validation

Note: Deperecated function - This script will validate an email address entered in the form field.

 

Example

Enter your email address for validation:

 

Script Source

<html>
<head><title></title></head>
<body>
<?php

if (isset($_POST['posted'])) {

$email = $_POST['email'];
$theresults = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email, $trashed);
if ($theresults) {
$isamatch = "Valid";
} else {
$isamatch = "Invalid";
}

echo "Email address validation says $email is " . $isamatch;
}

?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="posted" value="true">
Enter your email address for validation:
<input type="text" name="email" value="name@example.com">
<input type="submit" value="Validate"><input type="reset" value="Reset">
</form>
</body>
</html>

 

Please let me know if this script was helpful to you.

[rating]