Jump to content

Persistent form data?


kdreg

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/56123-persistent-form-data/
Share on other sites

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>';

?>

   

Link to comment
https://forums.phpfreaks.com/topic/56123-persistent-form-data/#findComment-277219
Share on other sites

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.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/56123-persistent-form-data/#findComment-277235
Share on other sites

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']);

}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/56123-persistent-form-data/#findComment-277288
Share on other sites

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);}

// }

?>

Link to comment
https://forums.phpfreaks.com/topic/56123-persistent-form-data/#findComment-277450
Share on other sites

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.