Vivid Lust Posted June 12, 2009 Share Posted June 12, 2009 Any ideas how I can keep current data in a form when the page is refreshed? Thanks, Jake. Link to comment https://forums.phpfreaks.com/topic/161944-keep-data-in-form-when-refreshed/ Share on other sites More sharing options...
Vivid Lust Posted June 12, 2009 Author Share Posted June 12, 2009 To add to that, the form directs to x.php and if there is an error it goes back to y.php (where the form is) Link to comment https://forums.phpfreaks.com/topic/161944-keep-data-in-form-when-refreshed/#findComment-854449 Share on other sites More sharing options...
Vivid Lust Posted June 12, 2009 Author Share Posted June 12, 2009 anyone? Link to comment https://forums.phpfreaks.com/topic/161944-keep-data-in-form-when-refreshed/#findComment-854532 Share on other sites More sharing options...
cunoodle2 Posted June 12, 2009 Share Posted June 12, 2009 This is a portion of code from a site I worked on before... <b>City:</b> <input type="text" value="<?php echo $city; ?>" name="city" size = "20"><br /><br /> <b>State:</b> <input type="text" value="<?php echo $state; ?>" name="state" size = "20"><br /><br /> <b>Zip:</b> <input type="text" value="<?php echo $zip; ?>" name="zip" size = "20"><br /><br /> If you are losing the actual values in transition of going from one page to the next then you may want to look into php sessions to store them temporarily on the second page and then refresh back to the first. There is a little more to it than that but I think you get the idea. The more important issue you need to deal with is why are you even leaving the page if everything is not properly in order? I submit to the page itself (the page the originally contained the form), do all error checking (on that page) and then IF and only IF everything is perfect THEN leave the page. If not then print the form to the screen again with all user variables already filled in for the end user. Otherwise you are just sending data back and forth and looking for issues. Link to comment https://forums.phpfreaks.com/topic/161944-keep-data-in-form-when-refreshed/#findComment-854561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.