Jump to content

Archived

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

joecooper

Back button with feilds

Recommended Posts

i have a script that has a html form at the end. the loaction of the post is $PHP_SELF, so it loads the same page and goes down the route of if the submit button was pushed ect.

as its a login form, forms can be accidenlty missed out so the user has to push back button and fill it, but when they go back, it resets the feilds, so the user has to retype everything, how can it be avoided?

Share this post


Link to post
Share on other sites
If they hit the back button, there isn't anything you can do. However, if, in your code you determine that something is incorrect, you can direct them back to the form and fill in the fields for them with the values that were posted. In other words, rather than them going "back", they would continue "forward" with you determining what happens.

Share this post


Link to post
Share on other sites
i see what you mean, but ive seen it be done before, in most website login forms it does it.

Share this post


Link to post
Share on other sites
Part of it, I think, depends on your browser, but you can't rely on your users having a specific browser.

Another alternative would be to use javascript to set a cookie, then each time a field is changed, have the js set a value in the cookie. Then just have it retrieve the values from the cookie. However, if your collecting credit card data and other sensitive stuff, that would probably be a bad idea as well...which brings me back to what I originally suggested.

Share this post


Link to post
Share on other sites
well if you are submitting the form to itself then you can use the value="" in each element if it is type text or password. Textarea, selects, checkbox, etc are different. So for text simply value="<? echo $_POST['fieldname']; ?>". You can look for my information on form elements to find out exactly how to give it a predefined value and use the <? echo $_POST['fieldname']; ?> to do so.

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.