Jump to content

Captcha Code


frank_solo

Recommended Posts

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";
  

?>

Link to comment
https://forums.phpfreaks.com/topic/261673-captcha-code/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/261673-captcha-code/#findComment-1340918
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.