PHP/Email/Email Validation
Email validation Demo
<source lang="html4strict">
<html> <head> <title>e-mail validator</title> </head> <body> <form name="form1" method="post" action="EMailValidation.php">
Enter an e-mail address to test</div></td>
</tr> | |
E-mail</td> |
<input type="text" name="email" size="30"> </td> </tr> |
<input type="submit" name="Submit" value="Submit"> </td> </tr> </table> </form> </body> </html>
</source>
Email validation with Regular Expressions<source lang="html4strict"> <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.ru"> <input type="submit" value="Validate"> </form> </body> </html> </source> |