Jump to content

how to accept and validate a specific email address in a form.


applebiz89

Recommended Posts

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

 

Archived

This topic is now archived and is closed to further replies.

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