Valid Email Check

Submitted by:David Villa

Date added:02 June, 2011

Category:PHP

This will check an email, to see if it is in a valid format.

Tags: verify email , check valid email

Code Snippet:

chkEmail.html
================

<form action="chkEmail.php" method="post">
Email: <input type="text" name="email">
<input type="submit" value="Check Email">
</form>


chkEmail.php
================

<?php
$email = $_POST['email'];
if(preg_match("~([a-zA-Z0-9!#$%&'*+-/=?^_`{|}~])@([a-zA-Z0-9-]).([a-zA-Z0-9]{2,4})~",$email)){
echo 'This is a valid email.';
}else{
echo 'This is an invalid email.';
}
?>
 
 

Comments