Here are two simple functions to validate name and e-mail .
int valName( string $arg1 )
- this function returns 1 if name is correct, 0 if incorrect
int valMail( string $arg1 )
- this function returns 1 if name is correct, 0 if incorrect
Here are two simple functions to validate name and e-mail .
int valName( string $arg1 )
- this function returns 1 if name is correct, 0 if incorrect
int valMail( string $arg1 )
- this function returns 1 if name is correct, 0 if incorrect
// valName()
function valName($name)
{
$name = preg_replace(‘/[\s]+/is’, ‘ ‘, $name);
$name = trim($name);
return preg_match(‘/^[a-z\s]+$/i’, $name);
}
// valMail()
function valMail($email)
{
$regexp='/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/';
return preg_match($regexp, trim($email));
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.