applebiz89 Posted October 8, 2010 Share Posted October 8, 2010 I want to make the form so only people with a specific email address can sign up to the site. So for example their ending email address was.... @something.apple.biz.com .. but to be accepted into the site, the email HAS to end with apple.biz.com. How could you validate it so it matches something specific like this. Here is my code at the moment which just checks that their is at least one . after the @ for it to be an acceptable email. If anyone could say what else to add to do this would be great if($email != '' && $register){ $emailcheck = explode("@", $email); $sql = "SELECT email FROM member WHERE email='$email'"; $query = mysql_query($sql); $emails = mysql_num_rows($query); if($emails != 0 ){ $alert .= '<p class="alert" style="clear:both;">That email address has already been registered</p>'; $register = false; }elseif(count($emailcheck) != 2){ $alert .= '<p class="alert" style="clear:both;">Please enter a valid email address</p>'; $register = false; }elseif(count($emailcheck) == 2){ $emailchecktwo = explode(".", $emailcheck[1]); if(count($emailchecktwo) < 2){ $alert .= '<p class="alert" style="clear:both;">Please enter a valid email address</p>'; $register = false; } } } Link to comment https://forums.phpfreaks.com/topic/215427-how-to-accept-and-validate-a-specific-email-address-in-a-form/ Share on other sites More sharing options...
BlueSkyIS Posted October 8, 2010 Share Posted October 8, 2010 if (stristr($email, 'apple.biz.com')) { // email is okay } else { // email is NOT okay } Link to comment https://forums.phpfreaks.com/topic/215427-how-to-accept-and-validate-a-specific-email-address-in-a-form/#findComment-1120228 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.