jibster Posted March 14, 2008 Share Posted March 14, 2008 Hi, quick question. So I have a form. I POST the variables to itself (PHP_SELF) then if validation is ok I send them to the next page. Now if they click the back button the values aren't re-populated. Is the way to repopulate by doing this? <input name="forenames" type="text" value="<? if(!empty($_SESSION['value_forenames'])) { echo $_SESSION['value_forenames']} ?>" /> Or is there a way to automatically "remember" what was in those fields. I'm sure this must have been answered before but my search didn't get any likely looking results. Cheers Link to comment https://forums.phpfreaks.com/topic/96084-best-way-to-re-populating-fields-after-clicking-back/ Share on other sites More sharing options...
soycharliente Posted March 14, 2008 Share Posted March 14, 2008 If you want them to be able to go back to the form and have it repopulate, I suggest you create a form on the next page with all the data that was posted in hidden field and give them a button to click that would simply repost it to that page. Link to comment https://forums.phpfreaks.com/topic/96084-best-way-to-re-populating-fields-after-clicking-back/#findComment-491893 Share on other sites More sharing options...
jibster Posted March 14, 2008 Author Share Posted March 14, 2008 Good idea that. Except if they ignore my button and click back (as I am prone to doing) it's all over for that method isn't it. Thanks Link to comment https://forums.phpfreaks.com/topic/96084-best-way-to-re-populating-fields-after-clicking-back/#findComment-492435 Share on other sites More sharing options...
soycharliente Posted March 14, 2008 Share Posted March 14, 2008 That's why you give it to them. As a favor. If they use your button, it works! Link to comment https://forums.phpfreaks.com/topic/96084-best-way-to-re-populating-fields-after-clicking-back/#findComment-492442 Share on other sites More sharing options...
vicodin Posted March 14, 2008 Share Posted March 14, 2008 Store the variables in a session Link to comment https://forums.phpfreaks.com/topic/96084-best-way-to-re-populating-fields-after-clicking-back/#findComment-492449 Share on other sites More sharing options...
Sulman Posted March 14, 2008 Share Posted March 14, 2008 The way you have done it (by echoing the session var in to the value field) is absolutely the way to do it! Link to comment https://forums.phpfreaks.com/topic/96084-best-way-to-re-populating-fields-after-clicking-back/#findComment-492473 Share on other sites More sharing options...
jibster Posted March 14, 2008 Author Share Posted March 14, 2008 Thank you for your replies. I'm probably wrong but isn't there a way to do it using header("Cache-control: private"); ...or similar header. Link to comment https://forums.phpfreaks.com/topic/96084-best-way-to-re-populating-fields-after-clicking-back/#findComment-492475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.