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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.