Jump to content

Archived

This topic is now archived and is closed to further replies.

coldkill

Keeping values in a form

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?

Share this post


Link to post
Share on other sites
Do you post a message and then go back a page and are you using FF? I find that FF tends to save your last sent data temporarily and so is a browser based feature rather than a PHP one. I believe the extension SessionSaver does this too.

Share this post


Link to post
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] ....

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.