healy787 Posted February 28, 2009 Share Posted February 28, 2009 I have recently been receiving the odd blank email from my website contact form. I have been using javascript validation and captcha to ensure all fields have been field but the form was still returned blank. I have just added some validation to my PHP script. Do you think the script below will be enough alongside the javascript to stop the blank mailings? Thanks for your help. <? $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 me"; $MsgHeader = "From: My 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>My website</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'>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'>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 : $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'>My mailing list : $mailing</font></font></td></tr> <tr><td> </td></tr> </table> </body> </html>"; if (!isset($_REQUEST['email'])) { header( "Location: http://www.mydomain.com/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.mydomain/thanks.html"); } ?> Link to comment https://forums.phpfreaks.com/topic/147332-is-this-spam-safe/ Share on other sites More sharing options...
corbin Posted February 28, 2009 Share Posted February 28, 2009 Since you're checking if $message is blank, you shouldn't ever get blank messages with that. Link to comment https://forums.phpfreaks.com/topic/147332-is-this-spam-safe/#findComment-773344 Share on other sites More sharing options...
healy787 Posted February 28, 2009 Author Share Posted February 28, 2009 brilliant so this should be enough to stop the blank messages? Link to comment https://forums.phpfreaks.com/topic/147332-is-this-spam-safe/#findComment-773347 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.