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.

Did you know?Explore Trending and Topic pages for more stories like this.
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

Simpler method of getting variables from mysql
Hi Guys,

I'm trying to streamline my CMS's code and as I was writing a new page it occured to

Do not allow posting of whitespace
Currently the script below works if the user does not type a name/message, but if i create a whitesp

php web service error
hey guys,
I'm working on a project requires the use of web services. I've been trying a few tutor

Storing user data help?
Hey Guys,

I'm not use if this question is to broad but I can always give you more informatio

retrieving images from mysql database using php
So I've been trying to figure out how to store images in a mysql database, and as far as i can tell

php and downloading
I want to use a php script to create two files. Then I want it to redirect (or whatever) to have tho

Need help with PHP/MySQL drop down menu
I need help on how I can implement a drop down menu which queries mysql database and output the avai

column name cancatenation within PL/SQL
I have a PLSQL store procedure, and the following statement is part of a subquery
fname||lnam

Feed Maker
Hi all.
First of all I must say I am not a php developer so I am afraid I don't know much about i

Dynamic Data + Sql Server 2005 Enterprise?
Hi! I have just started to learn ASP.NET, and it looks like it is quite a lot to learn. Im not reall

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