Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

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