GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 25-Jul-2007, 08:54
jimdavidson jimdavidson is offline
New Member
 
Join Date: Jul 2007
Posts: 9
jimdavidson is on a distinguished road

need help understand sessions


I'm teaching myself php, and I'm stuck. I have a two part form, each part opn a seperate page. I want to send info from page one to page two. Thought ok, I use session variables. The problem is that they don't get sent to the second page. All works fine on my local testing server, but when I go live session varables don't show. HAs this something to do with header? Is there another way to get to the second page?

Any help would be welcomed>


Here's part of the code

After user submits first form I load if to session variables in step one

PHP Code:

<?php
  $_SESSION['number_divers'] = $number_drivers;  
  $_SESSION['number_vehicles'] = $number_vehicles;  
  $_SESSION['current_insurance'] = $current_insurance;  
  $_SESSION['current_company'] = $current_company;  
  $_SESSION['refferal'] = $refferal;  

  // go to step two
 header('Location: http://example.com/my_auto_quotes_2.php');
}
?>


Step Two

PHP Code:

<?php
if (!isset($_SESSION)) {
  session_start();
}
echo $_SESSION['number_divers'];
echo  $_SESSION['number_divers'];  
echo  $_SESSION['number_vehicles'];  
echo  $_SESSION['current_insurance'];  
echo  $_SESSION['current_company'];  
echo  $_SESSION['refferal'];  
?>


I dont' see anything
  #2  
Old 25-Jul-2007, 09:12
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 751
admin will become famous soon enough

Re: need help understand sessions


Why can't you just process the input data from the first form, and add it as HIDDEN input data within the second form?
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #3  
Old 25-Jul-2007, 09:42
jimdavidson jimdavidson is offline
New Member
 
Join Date: Jul 2007
Posts: 9
jimdavidson is on a distinguished road

Re: need help understand sessions


No.

I need to know what's in $_SESSION['number_divers'] in order to format the second form i.e. I only want detailed driver info depending on the number of drivers. So if there's two I have driver 1 input detail section and driver 2 input detail sections. If there would be three or four I'd add more.

This all works fine when I'm testing on my localhost, but when I upload and try "live" the session variables don't go over. The only difference in the code is this

When local I use this:
header('Location: http://localhost/my_auto_quotes_2.php');

When I'm live I use this:
header('Location: http://example.com/my_auto_quotes_2.php');
  #4  
Old 27-Jul-2007, 12:01
jimdavidson jimdavidson is offline
New Member
 
Join Date: Jul 2007
Posts: 9
jimdavidson is on a distinguished road

Re: need help understand sessions


Problem solved. I stumbled accross this while pulling my hair out. Now I'm kicking myself.

For the header I had this...
header('Location: http://example.com/btracy_auto_quotes_2.php');

What I should have had was this...
header('Location: http://www.example.com/btracy_auto_quotes_2.php');

Three little w's made the difference, session variables now work.
 
 

Recent GIDBlogWelcome to Baghdad by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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 On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:44.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.