I have this nicely working form code for my website, but want to add my own simple captcha.
I want to add another field (which I can do) that forces users to type out what they see in an image I will insert - so there is only one right answer.
If, for example, telephone number required the numbers ‘1234’ to be added, how do I force users to do this?
Many thanks in advance!
[php]<?php
if(isset($_POST[‘submit’])) {
$name = $_POST['name']; // required
$telephone_number = $_POST['telephonenumber']; // required
$email_address = $_POST['emailaddress']; // required
$email_address_confirm = $_POST['emailaddressconfirm']; // required
$comments = $_POST['comments']; // required
if($name=='' ||
$telephone_number==’’ ||
$email_address==’’ ||
$email_address_confirm==’’ )
{
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 My 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 or Company Name: ".clean_string($name)."\n";
$email_message .= "Telephone Number: ".clean_string($telephone_number)."\n";
$email_message .= "Email Address: ".clean_string($email_address)."\n";
$email_message .= "Confirm Email Address: ".clean_string($email_address_confirm)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = ‘From: My Company’.
//'Reply-To: '.$email_from."\r\n" .
‘X-Mailer: PHP/’ . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
}
}
?>
[/php]