Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/63559-how-to-re-display-users-inputs-on-a-form/
Share on other sites

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.

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.