Jump to content

verify email not working


dyr

Recommended Posts

Hi all, I'm trying to add a section where it verifies that the email address is active in my register code.  My code below is it checking the dnsrr, and if it is not real, I have it die and an error message appears.  However, I am getting the error message all the time, whether I am sure the email is working or not.  First I declared my email variable ($email), and then after the code below I of course insert the new data in to the database.  I'm doing this over my localhost, so is that why it can't verify emails?  Or am I setting this up wrong?

 

<?php

$email = trim($_POST['email']);

if (False !== strpos($email, '@')) 
die("Please type in an email address.<br><br><a href=register.php>Continue</a>");

if(!@checkdnsrr($mailDomain,'MX'))
die("Not real email address.  Please try again.<br><br>
<a href=register.php>Continue</a>");

?>

Link to comment
Share on other sites

 

Ah, I see.  So how would I set this up similar to my example above (making an if false, die function)? 

 

<?php function validateEmailAddress($email) {
    if return filter_var(!$email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email);
}  die("That email address does not exist.");

?>

 

Code above doesn't work, but had to give it my best shot at trying to negate it. 

Link to comment
Share on other sites

Thanks for clearing that up!  Didn't think to use a !=1 option!  It checks to see if there is a @ and ., however does not actually verify that the email exists (for example, it let me register using hi@ashfioewhs.com).  Am I just not understanding the code correctly? 

Link to comment
Share on other sites

validating the syntax/format of an address is different from validating the actual existence of the address.

 

Consider if hosts allowed simple validation how much greater the spamming would become.  Best way to validate is send and email asking user to verify.

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.