NickG21 Posted December 27, 2006 Share Posted December 27, 2006 hey everyone, this is my code to validate an e-mail address. the email is accepted but these are the errors i receive, any idea where my problems are or how to fix them? thank youWarning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in .../emailcheck.php on line 15Warning: fsockopen(): unable to connect to :25 in .../emailcheck.php on line 15[code]<?phpfunction checkEmail($email) { if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) { return FALSE; } list($Username, $Domain) = split("@",$email); if(getmxrr($Domain, $MXHost)) { return TRUE; } else { if(fsockopen($Domain, 25, $errno, $errstr, 30)) { return TRUE; } else { return FALSE; } }}if (isset($_POST['submit'])) {$email = $_POST['email'];if(checkEmail('$email') == FALSE) { echo "E-mail entered is not valid.";} else { echo "E-mail entered is valid.";}}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><form method="post" action="emailcheck.php"><table class="qForm"><tr><td><a>Email:</a></td><td><input type="text" size="28" name="email" value-<? echo"$email"?>"><br/></td></tr><tr><input type="hidden" value="1"<td><input type="submit" name="submit" value="submit"></td></tr></table></form></body></html>[/code] Link to comment https://forums.phpfreaks.com/topic/31993-solved-validation-errors/ Share on other sites More sharing options...
trq Posted December 27, 2006 Share Posted December 27, 2006 You might want to error supress this line. eg;[code=php:0]if(@fsockopen($Domain, 25, $errno, $errstr, 30))[/code]Also note that variables do not need to be surrounded by quotes and in particular, surrounding them with single quotes meens they will not be parsed. So this line becomes....[code=php:0]if(checkEmail($email) == FALSE)[/code]And even better....[code=php:0]if (checkEmail($email))[/code]Does the same thing. Link to comment https://forums.phpfreaks.com/topic/31993-solved-validation-errors/#findComment-148480 Share on other sites More sharing options...
NickG21 Posted December 27, 2006 Author Share Posted December 27, 2006 that worked perfectly, with a few other adjustments, thank you very much thorpe Link to comment https://forums.phpfreaks.com/topic/31993-solved-validation-errors/#findComment-148492 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.