jaymc Posted December 13, 2006 Share Posted December 13, 2006 I have a form, which has some PHP validation in itSo for instance, if they fill in a field incorrect they will be notified and asked to go back and ammend that fieldHowever, when they go back, all the other day that they filled in is obviously gone..How can I get it so the data they entered previously is still in this boxes..May even be better using another language, just thought would be best to ask in here Link to comment https://forums.phpfreaks.com/topic/30420-filled-in-form/ Share on other sites More sharing options...
papaface Posted December 13, 2006 Share Posted December 13, 2006 A simple solution would be to echo the error message out and then display the form again using the $_POST["name"] in each value field to re-enter the data they entered before. This may be not be efficient, but it does the job. Link to comment https://forums.phpfreaks.com/topic/30420-filled-in-form/#findComment-140038 Share on other sites More sharing options...
trq Posted December 13, 2006 Share Posted December 13, 2006 When they submit the form store everything that was filled in in the $_SESSION array, then when they go back, repopulate the form from this array. Link to comment https://forums.phpfreaks.com/topic/30420-filled-in-form/#findComment-140040 Share on other sites More sharing options...
sanfly Posted December 13, 2006 Share Posted December 13, 2006 or put this in the header of the page[code=php:0]header("Cache-control: private");[/code] Link to comment https://forums.phpfreaks.com/topic/30420-filled-in-form/#findComment-140046 Share on other sites More sharing options...
jaymc Posted December 13, 2006 Author Share Posted December 13, 2006 [quote author=sanfly link=topic=118378.msg483710#msg483710 date=1165972204]or put this in the header of the page[code=php:0]header("Cache-control: private");[/code][/quote]Huh? I did actually try that and it didnt workI have signup.htm and signup.phpSignup.htm = form htmlsignup.php = php processI tried that header on both, never worked.. Link to comment https://forums.phpfreaks.com/topic/30420-filled-in-form/#findComment-140050 Share on other sites More sharing options...
sanfly Posted December 13, 2006 Share Posted December 13, 2006 Weird, ive used that on more than 10 websites successfullyTry shutting down the browser window and starting again incase its a session issue Link to comment https://forums.phpfreaks.com/topic/30420-filled-in-form/#findComment-140054 Share on other sites More sharing options...
rajesh Posted December 13, 2006 Share Posted December 13, 2006 Dear Friends,Some browsers doesnot support header("Cache-control: private"); full flexible so used the session variables to overcome the problem else you may used the $_POST. Link to comment https://forums.phpfreaks.com/topic/30420-filled-in-form/#findComment-140061 Share on other sites More sharing options...
simcoweb Posted December 13, 2006 Share Posted December 13, 2006 Hey thorpe, could you elaborate on that method a bit for us? Thanks! :) Link to comment https://forums.phpfreaks.com/topic/30420-filled-in-form/#findComment-140088 Share on other sites More sharing options...
hitman6003 Posted December 13, 2006 Share Posted December 13, 2006 Basically save $_POST to a $_SESSION element...[code]$_SESSION['previous_form_data'] = $_POST;[/code]Then to use it in the form:[code]echo '<input type="text" name="somefield" value="' . $_SESSION['previous_form_data']['somefield'] . '">[/code] Link to comment https://forums.phpfreaks.com/topic/30420-filled-in-form/#findComment-140091 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.