PHP Captcha Error help - replace the "die" command
Posted on
16th Feb 2014 07:03 pm by
admin
Hi All,
I am after a bit of help with a Captcha spam protection box.
The site gave me instructions, and all is well, apart from if the user give the wrong Captcha information...
The highlighted code is the part where i would like help, i would like the error message to appear in the same area/under submit button, in the form. For example: "*Wrong input for Captcha ", not take the user to a new screen, and make them hit the back button.
ANY help would be greatly appreciated, as im very new to PHP and not really sure whats what.
The code is:
***** PLEASE THE CODE TAG WHEN POSTING SOURCE CODE *****Line number On/Off | Expand/Contract<?phprequire_once('recaptchalib.php');$privatekey = "************************";$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); [color=#0000FF]if (!$resp->is_valid) { die ("The reCAPTCHA wasn't entered correctly. Please go BACK and try again..." . "(reCAPTCHA said: " . $resp->error . ")");}[/color] $to = "grant@********";$subject = "Enquiry";$name = $_REQUEST['name'] ;$phone = $_REQUEST['phone'] ;$email = $_REQUEST['email'] ;$message = $_REQUEST['message'] ;$headers = "From: $email";$body = "Enquiry From: $name.nn$name's Phone Number: $phone.nnEnquiry:n$message";$sent = mail($to, $subject, $body, $headers) ;if($sent){header( 'Location:******** TEST_ENVIRONMENT/Tatar/thank_you.php' ) ;}else{print "We encountered an error sending your enquiry"; }?>
Thank you in advance
No comments posted yet
Your Answer:
Login to answer
233
45
Other forums
How to use php and sql to check if values match the ones in a table (for logins)
How would I code it that the script takes two variables that are passed to it (UserID and PIN), and
Problem with "dynamic" index page
Hi. I have one question. In my index.php page I have this kind of code:
Code: // listaa sivut
Getting Resource id #11 while trying to connect..
So i tried using "DEFINE" for the first time and im using the variables i defined to conne
Passing variables with pagination - iterating through unique id per link
Hi everyone,
I have seen a few topics like this one. Still cant find the specific thing, so I am
Retreiving objects from Sessions
Hi all,
I am getting really frustrated with storing and retreiving objects from a session. Bu
Quick Question about echo value
Hey guys, I'm trying to get something to show differently in one of my scripts. I'm trying to make
grouping within a foreach?
hello all,
I currently have a list of products spit out from my db via a foreach loop. Right
ClientScript.RegisterClientScriptBlock Issue
This is what I haveview plaincopy to clipboardprint?Protected Sub posrback_Click(ByVal sender As Obj
Help building / using array
First - this is a cross-posting, if this is wrong I apologise! What started out as a MySQL query que
DB2 for z/OS, LUW, iSeries
Hello,
In this forum a lot of threads related to other members of the DB2 family than DB2 for z/OS