frank_solo Posted May 18, 2013 Share Posted May 18, 2013 I'm having a problem with captcha code. I keep getting the echo message "CAPTCHA CODE does not match!" everytime I send it . What am I not seeing? Please open my eyes to the error. Thanks in advance. <?php session_start(); include "config.php"; $id = (int)$_GET['id']; $res = mysql_query($query, $bd); $id = (int)$_GET['id']; $id = substr($id, 0,5); if($id < 1 || $id > 99999) exit; $query = "SELECT * FROM `units` WHERE `id` = $id"; $res = mysql_query($query, $bd); $result = mysql_fetch_assoc($res); $contact = $result['contact']; $phone = $result['phone']; $var = $result['email']; if (!empty($var)) { if (isset($_POST['submit'])) { if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) { $to = "$var"; // 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 = "My Domain RE:".$result['title'].""; $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 "<div align='left'<span style='font-family: Tahoma, Geneva, sans-serif; font-size: 14px; color: #F00;'>Email Has Been Sent</span></div>"; } else { echo "<div align='left'<span style='font-family: Tahoma, Geneva, sans-serif; font-size: 14px; color: #F00;'>CAPTCHA CODE does not match! </span></div>"; } } echo "<div align='left'><span style='font-family: Tahoma, Geneva, sans-serif; font-size: 14px; color: #00F;'>Email: ".$result['contact']."</span></div> <form method='post' action='apt.php?id=$id' name='contact''> <input name='name' type='text' size='40' placeholder='Name'/><br> <input name='email' type='text' size='40' placeholder='Email'/><br> <input name='phone' type='text' size='40' placeholder='Phone'/><br> <textarea name='msg' cols='29' rows='4'></textarea><br> <div align='left'><img src='http://www.mydomain.co/CaptchaSecurityImages.php?width=100&height=40& characters=5' alt='captcha' width='75px'/><br><input name='security_code' type='text' id='security_code' /><input type='submit' value='Send' class='button' name='submit' /></div> </form><br><br><br>";}?> Quote Link to comment Share on other sites More sharing options...
frank_solo Posted May 19, 2013 Author Share Posted May 19, 2013 Ok so instead of using captcha code I will be using a question instead. It works but now how can I use print isset on this: <?php $var = $result['email']; if (!empty($var)) { if (isset($_POST['submit'])) { if(isset($_POST['answer']) && $_POST['answer'] == '2'){ $to = "$var"; // change to your email address $name = htmlspecialchars ($_POST['name']); $email = htmlspecialchars ($_POST['email']); $phone = htmlspecialchars ($_POST['phone']); $msg = htmlspecialchars ($_POST['msg']); $d = date('l dS \of F Y h:i:s A'); $sub = "My Domain RE:".$result['title'].""; $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 "<div align='center'<span style='font-family: Tahoma, Geneva, sans-serif; font-size: 14px; color: #F00;'>Email Has Been Sent</span></div>"; } else { echo "<div align='center'<span style='font-family: Tahoma, Geneva, sans-serif; font-size: 14px; color: #F00;'>ANSWER does not match! </span></div>"; } } echo "<div align='center'><span style='font-family: Tahoma, Geneva, sans-serif; font-size: 14px; color: #00F;'>Email: ".$result['contact']."</span></div> <form method='post' action='apt.php?id=$id' name='contact' onSubmit='return Blank_TextField_Validator()'> <input name='name' type='text' size='40' placeholder='Name' value='".preg_replace('/[^a-z\-_0-9\.:\/]/i','',$_POST['name'])."'/><br> <input name='email' type='text' size='40' placeholder='Email' value='".preg_replace('/[^a-z\-_0-9\.:\/]/i','',$_POST['email'])."'/><br> <input name='phone' type='text' size='40' placeholder='Phone' value='".preg_replace('/[^a-z\-_0-9\.:\/]/i','',$_POST['phone'])."'/><br> <textarea name='msg' cols='29' rows='4' value='".preg_replace('/[^a-z\-_0-9\.:\/]/i','',$_POST['msg'])."' id='msg'></textarea><br> <div align='left'><span style='font-family: Tahoma, Geneva, sans-serif; font-size: 12px; color: #000;'>What is 2 + 2? </span><br><span style='font-family: Tahoma, Geneva, sans-serif; font-size: 12px; color: #000;'>Answer: </span><input name='answer' type='text' id='answer' size='3' maxlength='3' /><input type='submit' class='button4' value='Send' name='submit' /></div> </form><br><br><br>";}?> Quote Link to comment 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.