sidd111 Posted January 6, 2014 Share Posted January 6, 2014 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 Quote Link to comment Share on other sites More sharing options...
sidd111 Posted January 6, 2014 Author Share Posted January 6, 2014 mods please help me its urgent .. I am in trouble ..Please help me fast Quote Link to comment Share on other sites More sharing options...
PravinS Posted January 6, 2014 Share Posted January 6, 2014 (edited) if you want to use server side valiation then you can use "filter_var" function to check the email or else you can use javascript email validation http://www.php.net/manual/en/function.filter-var.php Edited January 6, 2014 by PravinS Quote Link to comment Share on other sites More sharing options...
sidd111 Posted January 6, 2014 Author Share Posted January 6, 2014 couldnt understand can you please edit the above code and give me. Quote Link to comment Share on other sites More sharing options...
dungpt29 Posted January 6, 2014 Share Posted January 6, 2014 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; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.