PHP Session Question

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Regicide

Thread Starter
Joined
Aug 8, 2003
Messages
307
I know that there is a way to have sessions save data from the previous page. This is so when you press the "back" button on IE, the text in the textboxes will still be there. Does anyone know how to do this?
 
Joined
Jul 8, 2002
Messages
14,681
PHP can only save the data if the form is submitted. But once the form field's value is in a variable, yes you can pre-populate a textbox with it.
If the person's name was in a session variable called NAME, you could use this for your textbox.

PHP:
<input type="text" name="name" value="<?php echo $_SESSION['NAME'] ?>">
 
Joined
Nov 2, 2000
Messages
637
there are actually several ways to do this. Session variables are generally forwned upon.

The way I get around them is that I have the form post to the same page it is on. I then detect if the submit button has been pressed with

if( isset($_POST['submit']) && $_POST['submit'] == "submit" ) {

This way all of my values from before are in the $_POST array on this page and if there is an error I can simply toss the values into and array and resue them on the same page. There is no need to use two pages to validate a form.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top