The most common verification we encounter is email address verification. Common on the site. Various Web page scripts are also commonly used "regular expressions" (regularexpression) to verify the e-mail address we enter and determine whether it is legal. Some can also break down the user name and domain name. Now implement the E-mail address verification program in PHP , using the PHP regular expression Library.
The source code is as follows:
<?PHPHeader("content-type:text/html; Charset=utf-8 " ); $reply= ""; if(isset($_post["Email_address"]) ) { $email _address=$_post["Email_address"]; $pattern= "/^ ([0-9a-za-z\\-_\\.] +) @ ([0-9a-z]+\\. [A-z] {2,3} (\\. [A-z] {2})?) $/i "; if(Preg_match($pattern,$email _address ) ) { $reply= "The email address you entered is legal <br/><br/>\n"; $user _name=Preg_replace($pattern, "$",$email _address ); $domain _name=Preg_replace($pattern, "$",$email _address ); $reply. = "User name:".$user _name." <BR/>\n "; $reply. = "Domain name:".$domain _name." <BR/>\n\n "; } Else { $reply= "The email address you entered is not valid"; } }?><!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"Lang= "zh"Xml:lang= "zh"><Head><title>e-mail Address verification Program</title></Head><Bodystyle= "Text-align:center;"><H1>e-mail Address verification Program</H1><formAction="#"Method= "POST">Please enter e-mail address:<inputname= "Email_address"type= "text"style= "width:300px;" /><BR/><inputtype= "Submit"value= "Verify e-mail Address" /></form><?PHPEcho $reply;?></Body></HTML>
PHP Regular Expressions