Jump to content

email validator not operating


sphinx

Recommended Posts

Hello,

 

the below validator keeps saying invalid email, can you notice any issues:

 

<form name="input" action="check.php" method="post">
Username: <input type="text" id="email" name="email" />
<input type="submit" value="Submit" />
</form> 

 

Check.php

<?php
if (isset($_REQUEST['email']))
{
$email = trim($_POST['email']);  
if(!checkEmail($email)) { 
echo 'Invalid email address!';
}
else 
{
echo 'Email address is valid';
}
}

function checkEmail($email) {
if(preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $email)) {
list($username,$domain)=split('@',$email);
if(!checkdnsrr($domain, 'MX')) {
return false;
}
if(!fsockopen($domain,25,$errno,$errstr,30)) {
return false;
}
return true;
}
return false;
}

?>

 

Many thanks

Link to comment
https://forums.phpfreaks.com/topic/251751-email-validator-not-operating/
Share on other sites

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.