Jump to content

Back button with feilds


joecooper

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?
Link to comment
https://forums.phpfreaks.com/topic/4652-back-button-with-feilds/
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.
Link to comment
https://forums.phpfreaks.com/topic/4652-back-button-with-feilds/#findComment-16282
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.
Link to comment
https://forums.phpfreaks.com/topic/4652-back-button-with-feilds/#findComment-16289
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.
Link to comment
https://forums.phpfreaks.com/topic/4652-back-button-with-feilds/#findComment-16304
Share on other sites

Archived

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

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