Retaining HTML form values when going "back" a pag

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
andyhough
Forum Newbie
Posts: 5
Joined: Mon Jan 19, 2004 4:09 am

Retaining HTML form values when going "back" a pag

Post by andyhough »

Hi all,

A quick question... I have setup an online application form that allows users' to apply for jobs online to my current company. When they submit the form it checks a few fields for validation. If these are incorrect then there is an option to go back and change these values (using the javascript back browser command). When the screen goes back it loses all the HTML values in the form and the user has to start again. This wouldn't be too much of a problem on a small form but this would take about 30-45mins to fill out so needless to say i need to solve this one :)

Any help would be appreciated guys, i have searched the forums and cannot really find a viable solution at this time.

Thanks in advance

Andy :lol:
User avatar
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

Post by lazersam »

This is just off the top of my head... what about adding the "value=" statement in the form field and starting up session variables that can carry the info back to the original page? I havent tried it with the "java back".

Just a passing thought.
andyhough
Forum Newbie
Posts: 5
Joined: Mon Jan 19, 2004 4:09 am

Post by andyhough »

If you mean setting each form value=$value i have tried this and it doesn't seem to work :(

I've tried registering the Globals on the page too but nothing i attempt appears to work.. hmmm

Good one this :!:

Cheers anyway :)
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

why do the users have to "go back", that is just annoying, why not just show the form again and highligh the fields that were incorrect/missing.

Mark
andyhough
Forum Newbie
Posts: 5
Joined: Mon Jan 19, 2004 4:09 am

Post by andyhough »

could do, could do.. but i would still like to know how this is done if anyone has any suggestions just for the point of knowing it for the future. I don't want to avoid doing something just because i don't know how to do it. You may be right in the way the form should go over itself but i want to also know how to retain values for future reference anyway.

Thanks for the suggestion though :D
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

there isn't a solution!

Read this http://www.experts-exchange.com/Web/Web ... 38517.html

I think it is client dependent.

Mark
andyhough
Forum Newbie
Posts: 5
Joined: Mon Jan 19, 2004 4:09 am

Post by andyhough »

I thought this too, although it does seem to work with some forms available on the Internet. (not using the same page technique).

surely there is a way. I know there is a meta tage called "no-cache". Can this be reversed maybe so it caches the page values?
andyhough
Forum Newbie
Posts: 5
Joined: Mon Jan 19, 2004 4:09 am

Post by andyhough »

I have managed to solve the problem now. Just for the record it is possible. I added the following lines above my page:

session_cache_limiter("public");
header("Cache-control: private");

This seemed to force the page into holding the values in the fields.

Thanks for everyone's help though, much appreciated :)
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

i wouldn't rely on it tho
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

set steps and save data

Post by djot »

-
hi,

my solution was to first of all not rely on java(<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>)script and (turned off!?)cookies.

I did add an id (session, token) whatever you call it to my action=url in the form. (may be input type=hidden also for sure)

this token is saved to a database with the current step being performed. Now you can save each step and related data to the database. now you are able to able to go back, read out the data from step x (previous, same, first etc.) out of the db and put it back into the form. It's a lot of work, so i won't do that for too many forms. better find an an intelligent object related solution for many forms/steps.

djot
Post Reply