I'm a newbie so excuse me if question could be stupid
I have a webpage where i have placed a form html with recaptcha validation
I have grabbed on the net following code :
and form html:Code:<script type="text/javascript"> function validateCaptcha() { challengeField = $("input#recaptcha_challenge_field").val(); responseField = $("input#recaptcha_response_field").val(); //alert(challengeField); //alert(responseField); //return false; var html = $.ajax({ type: "POST", url: "http://mysite.com/script.php", data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField, async: false }).responseText; if (html.replace(/^\s+|\s+$/, '') == "success") { $("#show").html("Success. Submitting form."); return false; // Uncomment the following line in your application //return true; } else { $("#show").html("Your captcha is incorrect. Please try again"); Recaptcha.reload(); return false; } } </script>
On the file: script.php i have placed php code:Code:<form action="#" method="post" onSubmit="return validateCaptcha()"> <p><?php echo recaptcha_get_html($publickey);?></p> <p style="color: red;" id="show"> </p> <input type="submit" name="Submit" value="Submit"> </form>
the code work but i don't want display in my webpage only messages:PHP Code:<?php
require_once('controllers/recaptchalib.php');
$privatekey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
# was there a reCAPTCHA response?
{
$response = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$response->is_valid) {
echo 'ERROR: The recaptcha code was not entered correctly or expired.';
die;
}
else
echo "success";
}
?>
"Your captcha is incorrect. Please try again" if code is incorrect and
"Success. Submitting form." if code is correct.
But if the code is correct i want display under sentence "Success. Submitting form." the content of script.php ie print a table or whatever script contain obviously without reloading webpage or redirect to another page
How to?
thanks


Reply With Quote

Bookmarks