session - save data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shawnews

    #1

    session - save data

    Hi,

    I would like to enable ppl a country choice on the first page and it should
    be saved while they're resting on my site so i can pre-select it on the
    contact form, I tried following:
    [top of index.php - nothing above]
    <?php
    session_start() ; // start up your PHP session!
    if ($_POST['country'])
    {
    $_SESSION['country']=$_POST['country'];
    echo "counry's been saved as: ".$_SESSION['country'];
    }
    ?>
    [/top of index.php - nothing above]
    [contact.php (where i wanna use the info)]
    <?php
    if ($_SESSION['country'])
    {
    echo $_SESSION['country'];
    }
    ....
    ....
    [/contact.php (where i wanna use the info)]
    it wouldn't echo anything on contacvt.php... .what have i forgotten/overseen?
    Help apprecaited!
    Thanks very much!

    roN


  • roN

    #2
    Re: session - save data

    "shawnews" <example@exampl e.comwrote in message
    news:GjEdh.4383 00$R63.352280@p d7urf1no...
    Hi,
    >
    I would like to enable ppl a country choice on the first page and it
    should be saved while they're resting on my site so i can pre-select it on
    the contact form, I tried following:
    [top of index.php - nothing above]
    <?php
    session_start() ; // start up your PHP session!
    if ($_POST['country'])
    {
    $_SESSION['country']=$_POST['country'];
    echo "counry's been saved as: ".$_SESSION['country'];
    }
    ?>
    [/top of index.php - nothing above]
    [contact.php (where i wanna use the info)]
    <?php
    if ($_SESSION['country'])
    {
    echo $_SESSION['country'];
    }
    ...
    ...
    [/contact.php (where i wanna use the info)]
    it wouldn't echo anything on contacvt.php... .what have i
    forgotten/overseen?
    Help apprecaited!
    Thanks very much!
    Got it, thank you anyways, i just needed to start the session by
    "session_start( ); " in contact.php as well :)
    Thanks!

    roN


    Comment

    Working...