Jump to content

Email validation check


sidd111

Recommended Posts

I need to check if the input is a valid email or not if the email is not valid then it would ask again for the mail address  without refreshing the whole page.

</script>
<?php
error_reporting(E_ALL);
if($_POST['submit']=="India")
{
  if(isset($_POST['EMAIL']))
{ //only do file operations when appropriate
        $a = $_POST['EMAIL'];
        $myFile = "email_users.txt";
$d=date("d-m-y");
$r="\n";
$s=$_POST['submit'];
    $fh = fopen($myFile, 'a+') or die("can't open file");
        fwrite($fh, $a.','.$d.','.$s.','.$r);
        fclose($fh);
}
}
if($_POST['sub']=="Overseas")
{
  if(isset($_POST['EMAIL']))
{ //only do file operations when appropriate
        $b = $_POST['EMAIL'];
        $my = "email_users.txt";
$e=date("d-m-y");
$t="\n";
$u=$_POST['sub'];
    $f = fopen($my, 'a+') or die("can't open file");
        fwrite($f, $b.','.$e.','.$u.','.$t);
        fclose($f);
}
}
//header("location:http://www.xyz.com");
?>

Please help me urgently

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/285131-email-validation-check/
Share on other sites

 

 

I need to check if the input is a valid email or not if the email is not valid then it would ask again for the mail address  without refreshing the whole page.

 

The best way to solve your problem is testing email address at client side using a JavaScript function as the following:

function checkemail(emailStr)
{
    var emailPat = /^([A-Za-z0-9]+[_\-\.]?[A-Za-z0-9]+)+\@([A-Za-z0-9]+[\-\.]?[A-Za-z0-9]+)+(\.[A-Za-z]+)$/;
    if (!emailPat.test(emailStr))
    {
        return false;
    }

    return true;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.