Giarc86
Expert Member
- Joined
- May 28, 2008
- Messages
- 1,243
- Reaction score
- 4
I put Captcha on a form of mine, but instead of redirecting it to another page I put the form submission on the same page. It submits the data no problem. However it doesn't display the "Incorrect" message when it isn't entered correctly. It doesn't allow the form to be submitted though, but I can't think were the incorrect message is supposed to go.
Been struggling with this the morning, sure it's something simple.
If someone could help would be appreciated.
Thanks
Been struggling with this the morning, sure it's something simple.
If someone could help would be appreciated.
Thanks
PHP:
<form action="new.php" method="post">
<?php
$publickey = "mykey";
$privatekey = "mykey";
include('recaptchalib.php');
$resp = null;
$error = null;
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
echo "Submitted Successfully";
if ($_POST["email"]<>'') {
$ToEmail = '[email protected]';
$EmailSubject = 'Somebody Please Contact Me Form ';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name and Surname: ".$_POST["namesurname"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "Cell Phone Number: ".$_POST["cell"]."<br>";
$MESSAGE_BODY .= "Other Comments: ".nl2br($_POST["comment"])."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
} else {
$error = $resp->error;
}
}
?>
<?php
} else {
?>