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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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