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 Link to comment https://forums.phpfreaks.com/topic/285131-email-validation-check/ 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 Link to comment https://forums.phpfreaks.com/topic/285131-email-validation-check/#findComment-1464040 Share on other sites More sharing options...
PravinS Posted January 6, 2014 Share Posted January 6, 2014 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 Link to comment https://forums.phpfreaks.com/topic/285131-email-validation-check/#findComment-1464045 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. Link to comment https://forums.phpfreaks.com/topic/285131-email-validation-check/#findComment-1464048 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; } Link to comment https://forums.phpfreaks.com/topic/285131-email-validation-check/#findComment-1464059 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.