denoteone Posted January 20, 2009 Share Posted January 20, 2009 I need to make an if statement that checks to see if my variable $_POST['email'] has @mysite.com in it. if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } this is where I need to make sure that the email has @mysite.com in it. If not then die('Your email must end in @mysite.com'); $usercheck = $_POST['email']; $check = mysql_query("SELECT email FROM users WHERE email = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the email '.$_POST['email'].' is already in use.'); } Link to comment https://forums.phpfreaks.com/topic/141657-solved-if-statement-to-check-email-variable/ Share on other sites More sharing options...
revraz Posted January 20, 2009 Share Posted January 20, 2009 Check the RegEx forums, they have stickies that point to common expressions you can use. Link to comment https://forums.phpfreaks.com/topic/141657-solved-if-statement-to-check-email-variable/#findComment-741516 Share on other sites More sharing options...
mikeg542 Posted January 20, 2009 Share Posted January 20, 2009 I'd do something along the lines of $emailpieces = explode('@', $usercheck); if ($emailpieces[1] != 'mysite.com') { die('Sorry, that email is invalid.'); } Link to comment https://forums.phpfreaks.com/topic/141657-solved-if-statement-to-check-email-variable/#findComment-741520 Share on other sites More sharing options...
denoteone Posted January 20, 2009 Author Share Posted January 20, 2009 thanks for the help what are the RegEx forums is that a separate site? Link to comment https://forums.phpfreaks.com/topic/141657-solved-if-statement-to-check-email-variable/#findComment-741522 Share on other sites More sharing options...
revraz Posted January 20, 2009 Share Posted January 20, 2009 http://www.phpfreaks.com/forums/index.php/board,43.0.html Link to comment https://forums.phpfreaks.com/topic/141657-solved-if-statement-to-check-email-variable/#findComment-741523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.