AdRock Posted July 26, 2006 Share Posted July 26, 2006 I have a feedback form where the user has to enter a captcha images to send.If the user doesn't fill out any text fields but does complete the captcha image correctly, a blank email is getting sent and I get this error message but if the user does complete the form correclty the email is sent.[b]Warning:[/b] Cannot modify header information - headers already sent by (output started at /home/adrock/public_html/jack/includes/captcha.php:24) in [b]/home/adrock/public_html/jack/includes/captcha.php [/b] on line [b]51[/b]I need some sort of vaildation where if there is any blank fields the form is shown and a message saying which field requires entryThe feedback form is displayed in index.php?page=contactcaptcha.php[code]<?// *** The CAPTCHA comparison - http://frikk.tk ***session_start();// *** We need to make sure theyre coming from a posted form -// If not, quit now ***if ($_SERVER["REQUEST_METHOD"] <> "POST") die("You can only reach this page by posting from the html form");// *** The text input will come in through the variable $_POST["captcha_input"],// while the correct answer is stored in the cookie $_COOKIE["pass"] ***if ($_POST["captcha_input"] == $_SESSION["pass"]){$myemail = "[email protected]"; $ccx = ""; if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) {echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n";}if(empty($visitor) || empty($visitormail) || empty($notes )) {echo "<h2>Use Back - fill in all fields</h2>\n";}echo $badinput;$todayis = date("l, F j, Y, g:i a") ;$subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \nMessage: $notes \n From: $visitor ($visitormail)\nAdditional Info : IP = $ip \nBrowser Info: $httpagent \n";$from = "From: $visitormail\r\n";if (($ccopy == "ccyes") && ($visitormail != "")) mail($visitormail, $subject, $message, $from);if ($myemail != "") mail($myemail, $subject, $message, $from);if ($ccx != "") mail($ccx, $subject, $message, $from);header('Location: http://www.mysite.co.uk/jack/index.php?page=thankyou');}else {header('Location: http://www.mysite.co.uk/jack/index.php?page=contact');}?>[/code]Anyone have any ideas how i can do this Link to comment https://forums.phpfreaks.com/topic/15693-feedback-form-help-with-captcha/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.