Monday, November 12, 2018

Function to validate email in PHP

<?php
function validate($mail){
if(strpos($mail,"@")>0 && strpos($mail,".")>0)
{
$atPos= strrpos($mail,"@");
$dotPos=strrpos($mail,".");
$len=strlen($mail);
if($dotPos>$atPos && strrpos($mail,".")<= $len-2){
return true;
}
else
return false;
}
else
return false;
}
?>

No comments:

Post a Comment