austin350s10 Posted May 29, 2009 Share Posted May 29, 2009 I am trying to use reCAPTCHA to validate the forms on my website. Problem is when the user enters a wrong security code they are sent to an error page with a redirect button to the form they were working on. When they are sent back to the form all the values in the form field are gone forcing the user to re-enter all their work. How can I make it so the form holds the values? I have heard that $_GET request would work somehow but I have no idea how to make that work. BTW....I am super new to PHP The example form is here http://www.affordablehomecare.org/functions/example-captcha.php Thanks, -Austin- Link to comment https://forums.phpfreaks.com/topic/160140-php-form-question/ Share on other sites More sharing options...
jonsjava Posted May 29, 2009 Share Posted May 29, 2009 try this: <?php //optout2.php if (isset($_POST) && !empty($_POST['email'])){ session_start(); $_SESSION['email'] = $_POST['email']; } ?> <?php //optout.php session_start(); if (isset($_SESSION['email'])){ $email_value = "value=\"".$_SESSION['email']."\" "; } else{ $email_value = ""; } ?> <form action="optout2.php" method="post"> <fieldset class="radius"> <legend>We're Sorry To See You Go</legend> <p>Please enter the email address you would like to have removed from our mailing list in the box below and click the unsubscribe button.</p> <dl> <dd><span id="sprytextfield1"> <input type="text" name="email" id="email" <?php print $email_value; ?>tabindex="1"/> I added the form just to show you how to do it, edit your form just adding the PHP I added. Add the PHP that I wrote at the top of each page (the stuff below optout.php in optout.php, and the stuff below optout2.php at the top of optout2.php). Link to comment https://forums.phpfreaks.com/topic/160140-php-form-question/#findComment-844899 Share on other sites More sharing options...
austin350s10 Posted May 29, 2009 Author Share Posted May 29, 2009 WOW!!!!!!.....Thank you sooooo much. One last thing though. If I were to use that same technique for forms with many inputs would I just copy paste the code above over and over with the other input id's? Thanks Again, -Austin- Link to comment https://forums.phpfreaks.com/topic/160140-php-form-question/#findComment-844941 Share on other sites More sharing options...
jonsjava Posted May 29, 2009 Share Posted May 29, 2009 yup. Link to comment https://forums.phpfreaks.com/topic/160140-php-form-question/#findComment-844943 Share on other sites More sharing options...
austin350s10 Posted May 29, 2009 Author Share Posted May 29, 2009 Is there any way to use that code for a select list? Link to comment https://forums.phpfreaks.com/topic/160140-php-form-question/#findComment-844985 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.