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 Like 45 Dislike
Previous forums Next forums
Other forums

help with insert
Hi there,

I am trying to insert some data into a database, but for some reason, it is not ins

admin with my register system?
Hey i wana make it so i can make a admin level on my register system , I'm kinda new to php to im no

Extracting URL pointer within XML tag
Hi.

I'm trying to extract text between two quotation marks in XML. For example, I want to ex

Update not working ... please help
Hi,

I am trying to update a row using an edit form by passing id of the row .. but it is not

Problem in String replace program's output
Hi all,
I was trying to make a program which accepts a string and replaces it with another stri

SQL query not working well
Hi,
I made a small table with 5 rows and want to make them an sql consult using rownum

dinamic "textboxes"?
Ey all, my first post here, i hope its not a hard one

I display mysql results in a table

preg_replace question
Hello!!

I hope someone can help me with preg_replace.

I load two tables from an extern

Problem related to Creation of PDF File?
Hi All,
I am facing a problem related to creation pdf file. when I am creating a pdf file of do

value not going in data base
hello friends....
i am having a working javascript....when i am selecting any

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash