How to exit TO a web page upon successful 'Recaptcha' input

Hello - Thanks for any help you can provide. Below is code I am using for “recaptcha” form validation. It works well EXCEPT that (instead of echoing ‘You got it!’) as shown below when the accurate words are entered, I want to exit to another web page. What is the php code that would replace echo “You got it!”; and instead exit (GO TO)to another web page? Thanks very much. linda jimerson

<?php

require_once(‘recaptchalib.php’);
$publickey = “6Le-0AEAAAAAAGV3Ln-w867BhcXcme3hvBBpyQy7”;
$privatekey = “6Le-0AEAAAAAAEYvsU9tKhDCaLC3wKhqaCDSvjQ_”;
$resp = null;
$error = null;
if ($_POST[“submit”]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER[“REMOTE_ADDR”],
$_POST[“recaptcha_challenge_field”],
$_POST[“recaptcha_response_field”]);
if ($resp->is_valid) {

echo "You got it! ";

} else {

$error = $resp->error;

}
}
echo recaptcha_get_html($publickey, $error);
?&g t;


well you can use a couple of methods.

In PHP you typically use the HEADER() function but it will generate an error if you have already passed any html (including even a space) because this sends data in the http header which ends at the first html sent.

You can suppress those errors in the PHP.INI but it’s not the best way to do it.

You can also use a meta redirect in the html head section.

Lastly you can echo some “JavaScript” which will also redirect as appropriate.

I prefer to use the header() function personally.

There are several ways to work around that, one being output buffering, another, more preferable, being moving all output as far below the PHP as possible. You won’t need to output anything while you’re still pre-processing is the thought, and although there can be situations where outputting is preferable during pre-processing, it’s usually something that happens last.

Agreed.

You will want to use header(‘location: http://www.targetwebsite.com’); or something like that.

Sponsor our Newsletter | Privacy Policy | Terms of Service