SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2003
    Location
    italy
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post sessions beginner question

    hi!, I´m new in this forum,
    I have one very beginner question:
    I have 4 pages, there is a form in the first with 40 fields, I need all the fields are available throw all the pages.
    the form page will be refreshed all the times the user wants, to make changes.

    page 1:
    [ PHP ]
    session_start();
    session_register("field1"); //register all the fields
    ...
    session_register("field40");

    if (!isset($field1)) { //fist time the form is charged (initial values)
    $field1 = "aa";
    ...
    $field40 = "40";
    } else { //not first time
    $field1 = $PHP_POST_VARS [“field1"]).
    $field40 = $PHP_POST_VARS [“field40"]).
    }

    <form action="<?=$SELF?>">
    <input type="text" name="field1" value="<?$field1?>">
    ...
    <input type="text" name="field40" value="<?$field40?>">
    <input tupe="submit" value="refresh">
    <a href=">next</a>

    [/ PHP ]

    is it correct?
    can I register all the variables of the form of another way? perhaps an array?
    can I use this variables throw all the pages?
    is any better way to do this?
    do you recommend me any tutorial about php sessions?

    thanks very much.

  2. #2
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would work ... You could use an array to shorten the code but it would do the same ...
    What you could use is instead of $PHP_POST_VARS use $_POST and also use $_SESSION !!! this way you always know where the info is coming from!!!

    $SELF should ofcourse be $PHP_SELF
    the neigbours (free) WIFI makes it just a little more fun


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
  •