tmyonline Posted August 6, 2007 Share Posted August 6, 2007 Guys: I have created a site that allows users to submit data. I made some fields mandatory so that if one of these fields is left blank, users will be prompted with a note that "You must complete contact information in order to submit comments". They will then be directed back to the submission page to fill out the missing fields (instead of filling out the entire form again; which can be frustrating). I have used session to record the entered data; for example: $_SESSION['phone'] = $_POST['phone']; but I don't know how to re-display this information on the input fields, I mean: where should I echo ($_SESSION['phone']) ? Any idea ? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/63559-how-to-re-display-users-inputs-on-a-form/ Share on other sites More sharing options...
hostfreak Posted August 6, 2007 Share Posted August 6, 2007 On your action page: //Contain the $_POST data in variables: $phone = $_POST['phone']; //Then assign to the $_SESSION superglobal: $_SESSION['phone'] = $phone; On your form page: In the input: value='<?php echo "$name"; ?>' The reason I suggest to assign to a variable is I think it is easier to work with just the variable name. That is personal preference though. Quote Link to comment https://forums.phpfreaks.com/topic/63559-how-to-re-display-users-inputs-on-a-form/#findComment-316746 Share on other sites More sharing options...
tmyonline Posted August 6, 2007 Author Share Posted August 6, 2007 Hi hostfreak: Thanks for your prompt reply. I thought in the input field, should the value be: value="<?php echo($_SESSION['phone']); ?>" instead ? Quote Link to comment https://forums.phpfreaks.com/topic/63559-how-to-re-display-users-inputs-on-a-form/#findComment-316762 Share on other sites More sharing options...
hostfreak Posted August 6, 2007 Share Posted August 6, 2007 Not if you assign the session to a variable like in my example. Otherwise, yes. Quote Link to comment https://forums.phpfreaks.com/topic/63559-how-to-re-display-users-inputs-on-a-form/#findComment-316795 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.