Jump to content

preserve form data after captcha test


gckmac

Recommended Posts

I need to preserve the data entered into form fields in case of failure of a captcha test (I am using recaptcha).

 

The form <action> takes the user from form1.php to form2.php, which in turn returns the user to form1.php in case of captcha failure.

 

Below is the code on www.maine.info/form1.php.  Can anyone suggest how I can preserve the data in the fields on this form so the user does not have to reinput?

 

<script type="text/javascript">

var RecaptchaOptions = {

  theme : 'clean'

};

</script>

 

<form action="form2.php" method="post">

<p>Your name: <input type="text" name="name" /></p>

<p>Your age: <input type="text" name="age" /></p>

<?php

# Get the reCaptcha library

require_once("captcha/recaptchalib.php");

$publickey = "xxxxxx";

echo recaptcha_get_html($publickey);

?>

<p><input type="submit" /></p>

</form>

 

Thanks in advance,

gckmac

 

 

Link to comment
https://forums.phpfreaks.com/topic/156211-preserve-form-data-after-captcha-test/
Share on other sites

instead of going from form1.php to form2.php, just keep everything on form1.php, including the reCaptcha verification, that way, upon a bad captcha, you can just repopulate your form with $_POST variables.

 

then, just redirect upon a legit captcha.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.