1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

PHP Session Question

Discussion in 'Software Development' started by Regicide, Sep 26, 2003.

Thread Status:
Not open for further replies.
  1. Regicide

    Regicide Thread Starter

    Aug 8, 2003
    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?
  2. brendandonhu


    Jul 8, 2002
    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.

    <input type="text" name="name" value="<?php echo $_SESSION['NAME'?>">
  3. deuce868


    Nov 2, 2000
    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.
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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/167710

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice