Old 11-04-2008, 17:27   #1 (permalink)
Maciek
I like Iced Tea
 
Maciek's Avatar
 
Join Date: Nov 2007
Location: Kitchener.Ontario.Canada
Posts: 93
Send a message via MSN to Maciek
Posting SESSION Info

Hey. I have wrote a whole bunch of php

PHP Code:
$_SESSION['fname'] = $_POST['fname'];
    
$_SESSION['lname'] = $_POST['lname'];
    
$_SESSION['saddress'] = $_POST['saddress'];
    
$_SESSION['city'] = $_POST['city'];
    
$_SESSION['email'] = $_POST['email'];
    
$_SESSION['htelephone'] = $_POST['htelephone'];
    
$_SESSION['ftelephone'] = $_POST['ftelephone']; 

which stores all this information as cookies for a multipaged form. On the second page of the form it takes the previous data from the first page and emails it to my email. It then sends the person who inputed the data to another page. I want to post the data he or she wrote on that page. But I cant seem to make it work.

Example - Your first name is: $fname

I tired working with
PHP Code:
<?php echo $_REQUEST["fname"]; ?>
and other things. But how do I retrieve session data and post it? should this work? or did I screw something up with my session-ing of data?

any help is appreciated. thanks
  Reply With Quote
Old 12-04-2008, 02:45   #2 (permalink)
Shiro
shiro
 
Shiro's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 2,688
A couple points. First, you have to start the session on any page where you will set cookies, and any page where you will retrieve them, using this:

Code:
session_start();

If you aren't doing this, your sessions wont be set on pages where you set the, and wont be retrievable on pages where you retrieve them.

Next, dont use $_REQUEST["fname"] to retrieve the session variable, use the same code you used to set them:

Code:
echo $_SESSION["fname"];

As a side point, this:

Quote:
stores all this information as cookies for a multipaged form.

Isn't exactly correct. You aren't storing them as cookies, you are storing them as session variables. I think you probably just got the terminology mixed up, but they are two different things. Cookies are stored on the user's machine. Session variables are stored on the server, and an ID number that refers to that session is stored on the users machine.
  Reply With Quote
Old 12-04-2008, 11:41   #3 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
Why not just use hidden inputs to store the data from page to page?

Sessions is a can of worms.
  Reply With Quote
Old 12-04-2008, 20:05   #4 (permalink)
Maciek
I like Iced Tea
 
Maciek's Avatar
 
Join Date: Nov 2007
Location: Kitchener.Ontario.Canada
Posts: 93
Send a message via MSN to Maciek
Thanks. It worked awesome. I tried <?php echo $_SESSION["xxx"]; ?> before but I didn't start the session. Which I also considered doing. Another question- if session data is not deleted will it eventually fill up my server with useless crap? =P
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8