Jump to content

Keeping values in a form


coldkill
 Share

Recommended Posts

How do you keep values in a form which someone has entered.
IE with this forum if you reload your post a topic page it keeps the values you entered in the form.
For some reason i thought it was a header() output but i forgot what and can't find it anywhere now :S.

Any ideas?
Link to comment
Share on other sites

[!--quoteo(post=359406:date=Mar 28 2006, 02:22 PM:name=coldkill)--][div class=\'quotetop\']QUOTE(coldkill @ Mar 28 2006, 02:22 PM) [snapback]359406[/snapback][/div][div class=\'quotemain\'][!--quotec--]
How do you keep values in a form which someone has entered.
[/quote]

Generally, when the form is first submitted you save the values somewhere (a database is a good place).

And when the user goes back, you fetch the values from the database and then display the form with values in the right spots.

Is that what you mean? I have some examples of how I do something like that at [a href=\"http://www.skypaint.com/gavin/code/\" target=\"_blank\"]http://www.skypaint.com/gavin/code/[/a] ....
Link to comment
Share on other sites

I did this before with jsp by keeping an array of validated values (blank strings for invalid values) and printing them in the necessary input elements.

You can easily extend this to highlight the invalid fields by changing the CSS class of the input element.

[code]$values = array("name" => "Jiminy", "address" => "", "Post Code" => "RM7 4RT");

<input type="text" value="<?echo $values["name"]?>" />[/code]

I'm not sure for what purpose you need them, but I just wanted to make it more convenient for users who made a mistake.
Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

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