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
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;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.