joecooper Posted March 11, 2006 Share Posted March 11, 2006 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 More sharing options...
hitman6003 Posted March 11, 2006 Share Posted March 11, 2006 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 More sharing options...
joecooper Posted March 11, 2006 Author Share Posted March 11, 2006 i see what you mean, but ive seen it be done before, in most website login forms it does it. Link to comment https://forums.phpfreaks.com/topic/4652-back-button-with-feilds/#findComment-16284 Share on other sites More sharing options...
hitman6003 Posted March 11, 2006 Share Posted March 11, 2006 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 More sharing options...
txmedic03 Posted March 11, 2006 Share Posted March 11, 2006 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.