healy787 Posted February 24, 2009 Share Posted February 24, 2009 Hi guys. Im getting myself in a pickle. Here is what i have: <? $name = $_REQUEST['name'] ; $surname = $_REQUEST['surname'] ; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $subject1 = $_POST['subject1'] ; $mailing = $_POST['mailing'] ; $telephone = $_REQUEST['telephone'] ; $to = "[email protected]"; $subject = "Message From Letsgohost Website"; $MsgHeader = "From: Lestgohost Website <[email protected]>\n"; $MsgHeader .= "Bcc: <[email protected]> r\n"; $MsgHeader .= "MIME-Version: 1.0\n"; $MsgHeader .= "Content-type: text/html; charset=iso-8859-1\n"; $MsgBody = " <html> <head> <title>Letsgohost</title> </head> <body> <table style='padding-left:20px'> <tr><td> </td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Name : $name</font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Surname : $surname</font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'> </font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Email : $email</font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'> </font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Message subject : $subject1</font></font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'> </font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Message : $message</font></font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'> </font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Mailing : $mailing</font></font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'> </font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Telephone : $telephone</font></td></tr> <tr><td> </td></tr> </table> </body> </html>"; function checkEmail($email) { // checks proper syntax if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $email)) { return false; } // gets domain name list($username,$domain)=split('@',$email); // checks for if MX records in the DNS $mxhosts = array(); if(!getmxrr($domain, $mxhosts)) { // no mx records, ok to check domain if (!fsockopen($domain,25,$errno,$errstr,30)) { return false; } else { return true; } } else { // mx records found foreach ($mxhosts as $host) { if (fsockopen($host,25,$errno,$errstr,30)) { return true; } } return false; } } if (!isset($_REQUEST['email'])) { header( "Location: http://www.letsgohost.co.uk/contact.html" ); } elseif (empty($email) || empty($message) || empty($name)) { header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); header( "Cache-Control: no-cache, must-revalidate" ); header( "Pragma: no-cache" ); ?> <html> <head><title>Error</title></head> <body> <h1>Error</h1> <p> Oops, it appears you haven't filled in the form correctly. Please ensure ALL fields have been filled in correctly. Please use the BACK button in your browser and try again. </p> </body> </html> <?php } else { mail($to, $subject, $MsgBody, $MsgHeader); header("Location: http://www.letsgohost.co.uk/thanks.html"); } if(!is_numeric($_POST['telephone'])){ echo("Telephone must be numeric (numbers only)"); } ?> The form posts perfectly. The problem i have is when i add the function checkEmail. This seems to overide the other validation and allows me to leave the email box blank? When i remove the function the script works fine and i have to put a value in the email box. Obviously the email validator isnt working right. Any suggestions? Thanks people. Link to comment https://forums.phpfreaks.com/topic/146785-validation-query/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.