kdreg Posted June 18, 2007 Share Posted June 18, 2007 I just need someone to point me in the right direction. I've set up a form with captcha and if someone enters the wrong captcha info and returns to the form to fix it, the previously filled in data is wiped out. What do I need to add so that the information persists? Would it be a session or cookie or ???? Thanks. Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 18, 2007 Share Posted June 18, 2007 Neither.... <?php echo' <form method="post action="'.$_SERVER['PHP_SELF'].'"> <table> <tr><td><input type="text name="nombre" value="'.$_POST['nombre'].'"></td></tr> <tr><td><input type="submit name="submit value="doit!"></td></tr> </table> </form>'; ?> Quote Link to comment Share on other sites More sharing options...
kdreg Posted June 19, 2007 Author Share Posted June 19, 2007 Thank you, Caesar. I'm not sure if that would work in my case though... I'm very, very rusty though since I haven't been coding for so long and wasn't too proficient anyway. My form already posts to a separate page that processes the submitted information and verifies the captcha and has other routines that hopefully prevent email injection. So I wouldn't be able to use or incorporate what you showed me, would I? I already have: <form method="post" action="procform.php"> So can't use this? <form method="post" action="'.$_SERVER['PHP_SELF'].'"> Thank you. Quote Link to comment Share on other sites More sharing options...
kdreg Posted June 19, 2007 Author Share Posted June 19, 2007 Anyone???? I thought I'd try a cookie, testing with just the name field but it's still blank. Please, any guidance? I've been googling without success. Here's what I'm trying (I have a hidden field called BeenSubmitted in the form: <?php if ($BeenSubmitted) { setcookie($_POST['Name']); } ?> Quote Link to comment Share on other sites More sharing options...
kdreg Posted June 19, 2007 Author Share Posted June 19, 2007 Can someone explain why this doesn't work? (Sorry, the CODE button is not working for me to format the text below.) I need to get the form working and I've spent hours trying to find a solution, but I'm lost. Is this correct? Do I need to call the cookie out somehow? <?php if($_POST["submit"] == "Submit") { foreach($HTTP_POST_VARS as $key => $value) { // if ($value != ""); // $message .= $key . ": " . stripslashes(trim($value)) . "\n"; { setcookie($key, $value, time()+3600);} // } ?> Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 19, 2007 Share Posted June 19, 2007 Be much easier if you processed the form on the same page. You can include the code that does it, if the $_POST array has been set. *SHRUGS* Quote Link to comment Share on other sites More sharing options...
kdreg Posted June 20, 2007 Author Share Posted June 20, 2007 Thanks, when I have enough time I'll re-do the forms to submit to self and give that a try. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.