madness69 Posted January 25, 2011 Share Posted January 25, 2011 Hi guys, im having a problem, in my phpfile were is generated the action code form the contacts form is giving me a lot of trouble, im receiving a lot of blank emails, first i thiked was bots,im usign a captcha, but then i notice another thing, when i put the name of the file that generates the action in the browser this loads it and send it the black email. How can i prevent for my php action file to dont be loadit in the browser? Here is the code to you guys have a idea <?php $datahora = "DATA: <B>" . date("d/m/y - H:i:s") . "</B><BR><BR>"; foreach ($_POST as $campo => $valor) { if (($campo == 'imageField2_x') or ($campo == 'imageField2') or ($campo == 'imageField2_y') or ($campo == 'distrito') or ($campo == 'subimit_y') or ($campo == 'codigo') or ($campo == 'seguranca')) {}else { if ($valor <> '') { $campo = str_replace("_", " ",$campo); $campos .= strtoupper($campo) . ": <b>" . $valor . "</b><Br>"; } } } $www = "WWW.USA.COM"; $assunto = "CONTACT - USA - " . $www; $conteudo = "CONTACT - USA<br><br>" . $datahora . ($campos) . "<br>" . $www; $para = "[email protected]"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: USA <[email protected]>\r\n"; $headers .= "Reply-To: ".$_POST['email']."\r\n"; if ($_POST['codigo'] == $_POST['seguranca']) { if (mail($para,$assunto,$conteudo,$headers) == true){ ?> <script> alert('Sent sucess!'); window.location = 'contact.php'; </script> <? }} ?> Hope for some help Quote Link to comment https://forums.phpfreaks.com/topic/225678-action-file-executing-in-browser/ Share on other sites More sharing options...
Simon Mayer Posted January 26, 2011 Share Posted January 26, 2011 It looks like you are not validating contents before calling mail(). Try something like this. if ($_POST['codigo'] == $_POST['seguranca']) { if(strlen($_POST['relevantfieldname']) > 0) { if (mail($para,$assunto,$conteudo,$headers) == true) Quote Link to comment https://forums.phpfreaks.com/topic/225678-action-file-executing-in-browser/#findComment-1165264 Share on other sites More sharing options...
madness69 Posted January 26, 2011 Author Share Posted January 26, 2011 Thanks a Lot Simon, this worked, finally a forum that give me the answeer lool Quote Link to comment https://forums.phpfreaks.com/topic/225678-action-file-executing-in-browser/#findComment-1165272 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.