Jump to content

How to re-display users' inputs on a form ?


tmyonline

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.

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.