gckmac Posted April 30, 2009 Share Posted April 30, 2009 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 More sharing options...
9three Posted April 30, 2009 Share Posted April 30, 2009 You will need to use AJAX for this so the page does not reload. Link to comment https://forums.phpfreaks.com/topic/156211-preserve-form-data-after-captcha-test/#findComment-822450 Share on other sites More sharing options...
blueman378 Posted April 30, 2009 Share Posted April 30, 2009 or a simplier way would be to store all inputs in sessions, then reload them in the value="" param Link to comment https://forums.phpfreaks.com/topic/156211-preserve-form-data-after-captcha-test/#findComment-822558 Share on other sites More sharing options...
mrMarcus Posted April 30, 2009 Share Posted April 30, 2009 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. Link to comment https://forums.phpfreaks.com/topic/156211-preserve-form-data-after-captcha-test/#findComment-822562 Share on other sites More sharing options...
gckmac Posted April 30, 2009 Author Share Posted April 30, 2009 Thanks all. I will try working with these options and will report back early next week (have to travel this weekend). gckmac Link to comment https://forums.phpfreaks.com/topic/156211-preserve-form-data-after-captcha-test/#findComment-822592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.