Results 1 to 5 of 5

Thread: PHP remember (?)

  1. #1
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation PHP remember (?)

    So I'm building a 3 part (3 different pages) form. The first page is the actual filling out of the form. The 2nd page is there to allow the user to review the form and the 3rd page is the actual sending of the form.

    On the second page I have a "back" button in case the user needs to change something before sending. However, when the user clicks the back button (I'm currently using javascript:history.go(-1) ) all the fields are empty and they ideally should have the input the user just entered. So they should be "remembered."

    Does anyone know how to accomplish this? Every comment and help with this is greatly appreciated!

    Cheers,

    Jeff

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    set a cookie on the second page and retrieve on the first:
    PHP Code:
    <?php
    $_COOKIE
    ['something']=$_REQUEST['something'];
    ?>
    Code:
    <input type="text" name="something" value="<?php if(isset($_COOKIE['something'])) echo $_COOKIE['something']; ?>
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@ /\/\@|{
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  3. #3
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hmm, not working but may have something to do with using $_SESSION. I did notice that when I started using this that it no longer remembered the entries automatically.

  4. #4
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Oops! Newb mistake, I got it working now.

    Thanks!!

  5. #5
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    It's
    PHP Code:
    setcookie('something',$_POST['something']); //or $_GET 
    Don't use $_REQUEST, it's a security risk.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •