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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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] Quote Link to comment 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.. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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! :) Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.