beelzebomb Posted December 2, 2012 Share Posted December 2, 2012 I have this nicely working form code for my website, but want to add my own simple captcha. I want to add another field that forces users to type out what they see in a static image that I will insert - so there is only one right answer. If, for example, name required the word 'stan' to be added, how do I force users to do this? Many thanks in advance! <?php if(isset($_POST['submit'])) { $name = $_POST['name']; // required $telephone_number = $_POST['telephonenumber']; // required if($name=='' || $telephone_number=='' ) { die('You have not filled in all of the required fields - please hit your back button and try again!'); } else{ $email_to = "[email protected]"; $email_subject = "Contact from company"; $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Telephone Number: ".clean_string($telephone_number)."\n"; // create email headers $headers = 'From: Company'. //'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/271506-force-users-to-type-specific-word-in-php-form/ Share on other sites More sharing options...
MDCode Posted December 2, 2012 Share Posted December 2, 2012 Look into google ReCaptcha. We are not here to code for you, we are here to help you. Quote Link to comment https://forums.phpfreaks.com/topic/271506-force-users-to-type-specific-word-in-php-form/#findComment-1397033 Share on other sites More sharing options...
Jessica Posted December 3, 2012 Share Posted December 3, 2012 Uhm.... == is comparison. Quote Link to comment https://forums.phpfreaks.com/topic/271506-force-users-to-type-specific-word-in-php-form/#findComment-1397039 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.