session - save data

This is a discussion on session - save data within the PHP Language forums, part of the PHP Programming Forums category; Hi, I would like to enable ppl a country choice on the first page and it should be saved while ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-06-2006
shawnews
 
Posts: n/a
Default 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


Reply With Quote
  #2 (permalink)  
Old 12-06-2006
roN
 
Posts: n/a
Default Re: session - save data

"shawnews" <example@example.com> wrote in message
news:GjEdh.438300$R63.352280@pd7urf1no...
> 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


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:32 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0