How to validate whether an email address is in the correct format
This code will explain how to validate an email address and then accept it for processing/using. If you find this code useful, please vote for me.
AI
AI-sammanfattning: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Källkod
<PRE>
<font size=2 face=verdana,arial,helvetica>
<?
// Author : Joel Agnel
$address = "name@emailaddress.com";
//The email address that is to validated
$expression = "^[_A-Za-z0-9-]+@[_A-Za-z-]+(\.[A-Za-z]+)(\.[A-Za-z]+)*$";
//The expression that describes
//the pattern the address should have
if(!ereg("$expression",$address)) { //if $address is not matching to $expression
echo "Sorry wrong address"; // not valid
} else { // else it is valid
echo "The address is valid";
}
?>
<a href="mailto:joelagnel@siteskool.com">Email me</a> for any help with this code
</PRE>
Originalkommentarer (3)
Återställd från Wayback Machine