frank_solo Posted April 27, 2012 Share Posted April 27, 2012 Can anyone please take a quick glance at this form the captcha messages are not appearing correctly. The message keeps getting sent. Thank You <?php if(($_SESSION['security_code'] != $_POST['security_code']) || (empty($_SESSION['security_code'])) ){ $to = "info@*******.com"; // change to your email address $name = htmlentities ($_POST['name']); $email = htmlentities ($_POST['email']); $phone = htmlentities ($_POST['phone']); $msg = htmlentities ($_POST['msg']); $d = date('l dS \of F Y h:i:s A'); $sub = "form to mail"; $headers = "From: $name <$email>\n"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\n"; $mes = "phone: ".$phone."\n"; $mes .= "Message: ".$msg."\n"; $mes .= "Name: ".$name."\n"; $mes .= 'Email: '.$email."\n"; $mes .= 'Date & Time: '.$d; { mail($to, $sub, $mes, $headers); } echo "<p> </p><p> </p><p> </p><br />CAPTCHA CODE does not match! <p> </p><p> </p><a href='javascript:javascript:history.go(-1)'>Click here to go back to previous page</a>"; } else echo "THANK YOU"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/261673-captcha-code/ Share on other sites More sharing options...
dragon_sa Posted April 27, 2012 Share Posted April 27, 2012 This line if(($_SESSION['security_code'] != $_POST['security_code']) || (empty($_SESSION['security_code'])) ){ should be if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ){ as this section of the code wants to send the message so it must comply to your if statement, you were saying if it does not equal the code or the code is empty send the message Quote Link to comment https://forums.phpfreaks.com/topic/261673-captcha-code/#findComment-1340918 Share on other sites More sharing options...
dragon_sa Posted April 27, 2012 Share Posted April 27, 2012 also this { mail($to, $sub, $mes, $headers); } should be mail($to, $sub, $mes, $headers); } else { Quote Link to comment https://forums.phpfreaks.com/topic/261673-captcha-code/#findComment-1340919 Share on other sites More sharing options...
frank_solo Posted April 27, 2012 Author Share Posted April 27, 2012 Thank You so much Dragon_sa! That worked perfectly! Quote Link to comment https://forums.phpfreaks.com/topic/261673-captcha-code/#findComment-1340920 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.