Page 1 of 2

Why are session variables not passing to next page

Posted: Thu Jul 26, 2007 10:22 am
by jimdavidson
Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I'm new at php (teaching myself from books)  I have a two page form, I need to forward input from first page to build the form on the second page.  When I run this on my testing site(localhost) allworks fine. When I upload to the remote server and run it the session variables never make it to the second page.   Can someone look at the code and tell me what I'm doing wrong?

Thanks
Here's the code

Code: Select all

<?php  session_start();
$number_drivers = '';
$number_vehicles = '';
$current_insurance = '';
$current_company = '';
$refferal = '';
// read somewhere to set session variables to nothing at beginning
  $_SESSION['number_divers'] = $number_drivers;  
  $_SESSION['number_vehicles'] = $number_vehicles;  
  $_SESSION['current_insurance'] = $current_insurance;  
  $_SESSION['current_company'] = $current_company;  
  $_SESSION['refferal'] = $refferal;  

if (array_key_exists('step_two', $_POST)) {
// continue to step two button clicked
  // remove escape characters from POST array
  if (get_magic_quotes_gpc()) {
    function stripslashes_deep($value) {
      $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
      return $value;
    }
    $_POST = array_map('stripslashes_deep', $_POST);
  } // end magic quotes
  // get input and store to session variables

  $_SESSION['number_divers'] = $_POST['number_drivers'];  
  $_SESSION['number_vehicles'] = $_POST['number_vehicles'];  
  $_SESSION['current_insurance'] = $_POST['current_insurance'];  
  $_SESSION['current_company'] = $_POST['current_company'];  
  $_SESSION['refferal'] = $_POST['refferal']; 
  // go to step two
 session_write_close();  
// depending on wheather I'm testing or live as to which header I use
// header('Location: http://localhost/btracy_auto_quotes_2.php');
header('Location: http://bobtracyinsurance.com/btracy_auto_quotes_2.php');
 exit;
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Free auto quotes at Bob Tracy Insurance serving Beaver County's Insurance needs">
<meta name="keywords" content="bob tracy insurance,insurance,beaver pa 15009,Beaver PA,15009,tracy,Bob Tracy,personal attention,quotes,free auto insurance quote,free quotes,car insurance">

<title>Get free auto insurance quotes at Bob Tracy Insurance</title>
<link href="CssFiles/tracy.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#auto1_main {position:absolute;
	width:713px;
	height:399px;
	z-index:1;
	left: 175px;
	top: 20px;
}
.style6 {font-size: 12px}
.left_info {font-size: small}
.style1 {font-size: 14px}
#menu {
	position:absolute;
	width:143px;
	height:640px;
	z-index:1;
	left: 3px;
	top: 1px;
	background-color: #547E29;
}
#tracy_slide {	position:absolute;
	width:140px;
	height:140px;
	z-index:5;
	left: 713px;
	top: 5px;
}
.style7 {font-size: x-small}
-->
</style>
</head>

<body>
<div id="auto1_main">
  <table width="700" border="0" align="center" cellpadding="0">
    <tr>
      <td><form id="auto_one" name="auto_one" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
        <table width="680" border="0" align="center" cellpadding="0">
          <tr>
            <td colspan="3"><div align="center">
              <h3>Auto Quote Step 1 of 2 </h3>
            </div></td>
            </tr>
          <tr>
            <td width="402"><h3>About You </h3></td>
            <td width="21">&nbsp;</td>
            <td width="249">&nbsp;</td>
          </tr>
          <tr>
            <td height="15">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">How many drivers are in your household? </td>
            <td>&nbsp;</td>
            <td><select name="number_drivers" id="number_drivers">
              <option value="" selected="selected">Please Select</option>
              <option value="1">One</option>
              <option value="2">Two</option>
              <option value="3">Three</option>
              <option value="4">Four</option>
              <option value="5">Five</option>
                        </select>
              <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td>&nbsp;<span class="style6">&nbsp; * Include yourself, your spouse, anyone of driving age in your household, and all other drivers of your vehicles.</span> </td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">How many vehicles are you insuring? </td>
            <td>&nbsp;</td>
            <td><select name="number_vehicles" id="number_vehicles">
              <option value="0" selected="selected">Please Select</option>
              <option value="1">One</option>
              <option value="2">Two</option>
              <option value="3">Three</option>
              <option value="4">Four</option>
              <option value="5">Five</option>
            </select>
              <span class="left_info">              *</span></td>
          </tr>
          <tr>
            <td class="left_info">&nbsp;&nbsp; * If zero, the remaining questions are optional </td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">Do you currently have auto insurance? </td>
            <td>&nbsp;</td>
            <td><select name="current_insurance" id="current_insurance">
              <option selected="selected">Please Select</option>
              <option value="Yes">Yes</option>
              <option value="Yes, I am on my parents policy">Yes, I am on my parents policy</option>
              <option value="No">No</option>
              <option value="No, my insurance ran out">No, my insurance ran out</option>
              <option value="No, my car broke down">No, my car broke down</option>
              <option value="No, I haven't owned a car recently">No, I haven't owned a car recently</option>
              <option value="No, I've never owned a car before">No, I've never owned a car before</option>
              <option value="No, I have a company car">No, I have a company car</option>
            </select>
              <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">What 
insurance company are you currently insured with, or previously insured 
with?</td>
            <td>&nbsp;</td>
            <td><select name="current_company" id="current_company">
              <option value=""> -- Please Select -- </option>
			  <option value="None">None</option>
          
            <option value="AIG" >AIG</option>
          
            <option value="Allstate" >Allstate</option>
          
            <option value="Amica" >Amica</option>
          
            <option value="Chubb" >Chubb</option>
          
            <option value="Country-Wide Ins Co" >Country-Wide Ins Co</option>
          
            <option value="Dairyland" >Dairyland</option>
          
            <option value="Deerbrook" >Deerbrook</option>
          
            <option value="Drive Insurance" >Drive Insurance</option>
          
            <option value="Encompass (CNA)" >Encompass (CNA)</option>
          
            <option value="Erie Insurance" >Erie Insurance</option>
          
            <option value="Farmers" >Farmers</option>
          
            <option value="Firemans Fund" >Firemans Fund</option>
          
            <option value="GEICO" >GEICO</option>
          
            <option value="GMAC (Integon)" >GMAC (Integon)</option>
          
            <option value="Great American" >Great American</option>
          
            <option value="Hartford" >Hartford</option>
          
            <option value="Insurequest" >Insurequest</option>
          
            <option value="Liberty Mutual" >Liberty Mutual</option>
          
            <option value="Mercury Casualty" >Mercury Casualty</option>
          
            <option value="Metropolitan" >Metropolitan</option>
          
            <option value="Nationwide" >Nationwide</option>
          
            <option value="NY Auto Insurance Plan (NYAIP)" >NY Auto Insurance Plan (NYAIP)</option>
          
            <option value="NY Central Mutual" >NY Central Mutual</option>
          
            <option value="One Beacon (CGU)" >One Beacon (CGU)</option>
          
            <option value="Other Not-Listed Ins Company" >Other Not-Listed Ins Company</option>
          
            <option value="Progressive Insurance Company" >Progressive Insurance Company</option>
          
            <option value="Prudential" >Prudential</option>
          
            <option value="Royal Sun Alliance" >Royal Sun Alliance</option>
          
            <option value="Safeco" >Safeco</option>
          
            <option value="State Farm" >State Farm</option>
          
            <option value="Statewide Ins Co" >Statewide Ins Co</option>
          
            <option value="Travelers" >Travelers</option>
          
            <option value="US Capital Ins Co" >US Capital Ins Co</option>
          
            <option value="USAA" >USAA</option>
          
            <option value="Utica Mutual Ins Co" >Utica Mutual Ins Co</option>
          
            <option value="Windsor" >Windsor</option>
          
            <option value="NYSIF" >NYSIF</option>
            </select>
              <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">How did you hear about us? </td>
            <td>&nbsp;</td>
            <td><select name="refferal" id="refferal">
                        <option value=""> -- Please Select -- </option>
          
            <option value="Current Client" >Current Client</option>
          
            <option value="Referral of Friend" >Referral of Friend</option>
          
            <option value="Yellow Pages" >Yellow Pages</option>
          
            <option value="Former Bob Tracy Client" >Former Bob Tracy Client</option>
          
            <option value="Newspaper-Insert" >Newspaper-Insert</option>
          
            <option value="Direct Mailer" >Direct Mailer</option>
          
            <option value="Saw Our Office" >Saw Our Office</option>
          
            <option value="Radio" >Radio</option>
          
            <option value="Netquote -purchased lead" >Netquote -purchased lead</option>
          
            <option value="Billboard" >Billboard</option>
          
            <option value="Erie from another agent/state" >Erie from another agent/state</option>
          
            <option value="Car Dealership" >Car Dealership</option>
          
            <option value="Internet / Our Website" >Internet / Our Website</option>
            </select>
              *</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><h3>Important Information</h3></td>
          </tr>
        </table>
		
        <table width="100%" border="1" cellpadding="5" cellspacing="0" bordercolor="#333333" class="content">
          <tr> 
            <td align="center"><div align="left" class="left_info">Information Disclosure: To provide 
                a quote, we will collect information from consumer reporting agencies, 
                such as driving record and claims history reports. We will also 
                review your credit report and use a credit-based insurance score 
                based on information contained in that report. An insurance score 
                uses information from your credit report to help predict how often 
                you are likely to file claims and how expensive those claims will 
                be. Typical items from a credit report that could affect a score 
                include, but are not limited to, the following: payment history, 
                length of reported credit history, number of loans and accounts 
                with current payment status, and number of inquiries. The information 
                used to develop the insurance score comes from one of the following 
                consumer reporting agencies: Experian, TransUnion, or Equifax. 
                Future reports may be used to update or renew your insurance. 
              </div></td>
          </tr>
        </table>		
		
		
		
        <table width="682" border="0" align="center" cellpadding="0" id="step_two">

          <tr>
            <td width="39">&nbsp;</td>
            <td width="228">&nbsp;</td>
            <td width="407"><input name="step_two" type="submit" id="step_two" value="Continue to Step Two" /></td>
          </tr>
          
		 </table>		
      </form>
      </td>
    </tr>
  </table>
</div>
<p>&nbsp;</p>

<div id="menu">

  <p>
  <p>&nbsp;</p>
	<p>&nbsp;</p>
    <script menumaker>document.write('<scr' + 'ipt src="images/mainmenu1.js">'+'</scr'+'ipt>');/*img src="images/mainmenu1.gif" moduleid="bob tracy (project)\mainmenu1_off.xws"*/</script>
  </p>
  
  <p>&nbsp; </p>
  <table width="140" border="0" cellpadding="0">
    <tr>
      <th width="184" class="whitefont" scope="col"><div align="center" class="left_info"> Bob Tracy Insurance </div></th>
    </tr>
    <tr>
      <td class="whitefont"><div align="center" class="left_info"> 433 State Street</div></td>
    </tr>
    <tr>
      <td class="whitefont"><div align="center" class="left_info"> Beaver, PA&nbsp; 15009</div></td>
    </tr>
    <tr>
      <td class="whitefont"><div align="center" class="style1">
        <div align="center"></div>
      </div></td>
    </tr>
    <tr>
      <td class="whitefont"><div align="center" class="left_info"> (724) 728 - 1200</div></td>
    </tr>
    <tr>
      <td class="whitefont">&nbsp;</td>
    </tr>
    <tr>
      <td class="whitefont"><div align="center">Monday thru Friday </div></td>
    </tr>
    <tr>
      <td class="whitefont"><div align="center">8:30 - 4:30 </div></td>
    </tr>
    <tr>
      <td class="left_info"><div align="center" class="whitefont style7">Evenings by appointment </div></td>
    </tr>
  </table>
  <p>&nbsp; </p>
</div>
</body>
</html>

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Jul 26, 2007 10:37 am
by miro_igov
The box in which you type your posts contains very useful buttons at top. You can place your code in php wrapper to look better.

What is the content of the 2nd script?

Posted: Thu Jul 26, 2007 10:46 am
by jimdavidson
Sorry, that was my first post, her goes I'll try to get page two correct.

Page two code

Code: Select all

<?php session_start();
$number_drivers = '';
$number_vehicles = '';
$current_insurance = '';
$current_company = '';
$refferal = '';
$driver_1_name = '';
$driver_1_first_name = ''; 
$driver_1_mi = '';
$driver_1_last_name = '';
$driver_1_address_1 = '';
$driver_1_address_2 = '';
$driver_1_city = '';
$driver_1_state = '';
$driver_1_zip = '';
$driver_1_residence = '';
$driver_1_home_phone = '';
$driver_1_other_phone = '';
$driver_1_email = '';
$driver_1_marital_status = '';
$driver_1_dob = '';
$driver_1_soc_sec = '';
//
$driver_2_name = '';
$driver_2_first_name = '';
$driver_2_mi = '';
$driver_2_last_name = '';
$driver_2_marital_status = '';
$driver_2_dob = '';
$driver_2_soc_sec = '';
$driver_2_relationship = '';
//
$driver_3_name = '';
$driver_3_first_name = '';
$driver_3_mi = '';
$driver_3_last_name = '';
$driver_3_marital_status = '';
$driver_3_dob = '';
$driver_3_soc_sec = '';
$driver_3_relationship = '';
//
$driver_4_name = '';
$driver_4_first_name = '';
$driver_4_mi = '';
$driver_4_last_name = '';
$driver_4_marital_status = '';
$driver_4_dob = '';
$driver_4_soc_sec = '';
$driver_4_relationship = '';
//
$driver_5_name = '';
$driver_5_first_name = '';
$driver_5_mi = '';
$driver_5_last_name = '';
$driver_5_marital_status = '';
$driver_5_dob = '';
$driver_5_soc_sec = '';
$driver_5_relationship = '';
//
$number_drivers = $_SESSION['number_divers'];
$number_vehicles = $_SESSION['number_vehicles'];
$current_insurance = $_SESSION['current_insurance'];
$current_company = $_SESSION['current_company'];
$refferal = $_SESSION['refferal'];
if (array_key_exists('submit_info', $_POST)) {
// submit button clicked
  // remove escape characters from POST array
  if (get_magic_quotes_gpc()) {
    function stripslashes_deep($value) {
      $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
      return $value;
    }
    $_POST = array_map('stripslashes_deep', $_POST);
  } // end magic quotes
  // get input
  $driver_1_first_name = trim($_POST['driver_1_first_name']);
  $driver_1_mi = trim($_POST['driver_1_mi']);
  $driver_1_last_name = trim($_POST['driver_1_last_name']);
  $driver_1_address_1 = trim($_POST['driver_1_address_1']);
  $driver_1_address_2 = trim($_POST['driver_1_address_2']);
  $driver_1_city = trim($_POST['driver_1_city']);
  $driver_1_state = trim($_POST['driver_1_state']);
  $driver_1_zip = trim($_POST['driver_1_zip']);
  $driver_1_residence = trim($_POST['driver_1_residence']);
  $driver_1_home_phone = trim($_POST['driver_1_home_phone']);
  $driver_1_other_phone = trim($_POST['driver_1_other_phone']);
  $driver_1_email = trim($_POST['driver_1_email']);
  $driver_1_marital_status = trim($_POST['driver_1_marital_status']);
  $driver_1_dob = trim($_POST['driver_1_dob']);
  $driver_1_soc_sec = trim($_POST['driver_1_soc_sec']);
  if ($number_drivers > 1) {  
  $driver_2_first_name = trim($_POST['driver_2_first_name']);
  $driver_2_mi = trim($_POST['driver_2_mi']);
  $driver_2_last_name = trim($_POST['driver_2_last_name']);
  $driver_2_marital_status = trim($_POST['driver_2_marital_status']);
  $driver_2_dob = trim($_POST['driver_2_dob']);
  $driver_2_soc_sec = trim($_POST['driver_2_soc_sec']);
  $driver_2_relationship = trim($_POST['driver_2_relationship']);
  }
  if ($number_drivers > 2) {  
  $driver_3_first_name = trim($_POST['driver_3_first_name']);
  $driver_3_mi = trim($_POST['driver_3_mi']);
  $driver_3_last_name = trim($_POST['driver_3_last_name']);
  $driver_3_marital_status = trim($_POST['driver_3_marital_status']);
  $driver_3_dob = trim($_POST['driver_3_dob']);
  $driver_3_soc_sec = trim($_POST['driver_3_soc_sec']);
  $driver_3_relationship = trim($_POST['driver_3_relationship']);
  }
  if ($number_drivers > 3) {
  $driver_4_first_name = trim($_POST['driver_4_first_name']);
  $driver_4_mi = trim($_POST['driver_4_mi']);
  $driver_4_last_name = trim($_POST['driver_4_last_name']);
  $driver_4_marital_status = trim($_POST['driver_4_marital_status']);
  $driver_4_dob = trim($_POST['driver_4_dob']);
  $driver_4_soc_sec = trim($_POST['driver_4_soc_sec']);
  $driver_4_relationship = trim($_POST['driver_4_relationship']);
  }
  if ($number_drivers > 4) {  
  $driver_5_first_name = trim($_POST['driver_5_first_name']);
  $driver_5_mi = trim($_POST['driver_5_mi']);
  $driver_5_last_name = trim($_POST['driver_5_last_name']);
  $driver_5_marital_status = trim($_POST['driver_5_marital_status']);
  $driver_5_dob = trim($_POST['driver_5_dob']);
  $driver_5_soc_sec = trim($_POST['driver_5_soc_sec']);
  $driver_5_relationship = trim($_POST['driver_5_relationship']);
  }
  // send  an email
  $driver_1_name = $driver_1_first_name;
  $driver_1_name = $driver_1_name.' ';
 
  if (!empty($driver_1_mi)) {
    $driver_1_name = $driver_1_name.$driver_1_mi;
    $driver_1_name = $driver_1_name.' ';
  }
  $driver_1_name = $driver_1_name.$driver_1_last_name;
  if ($number_drivers > 1) {
    $driver_2_name = $driver_2_first_name;
    $driver_2_name = $driver_2_name.' ';
    if (!empty($driver_2_mi)) {
      $driver_2_name = $driver_2_name.$driver_1_mi;
      $driver_2_name = $driver_2_name.' ';
    }
    $driver_2_name = $driver_2_name.$driver_2_last_name;
  }
  if ($number_drivers > 2) {
    $driver_3_name = $driver_3_first_name;
    $driver_3_name = $driver_3_name.' ';
    if (!empty($driver_3_mi)) {
      $driver_3_name = $driver_3_name.$driver_1_mi;
      $driver_3_name = $driver_3_name.' ';
    }
    $driver_3_name = $driver_3_name.$driver_3_last_name;
  }
  if ($number_drivers > 3) {
    $driver_4_name = $driver_4_first_name;
    $driver_4_name = $driver_4_name.' ';
    if (!empty($driver_4_mi)) {
      $driver_4_name = $driver_4_name.$driver_1_mi;
      $driver_4_name = $driver_4_name.' ';
    }
    $driver_4_name = $driver_4_name.$driver_4_last_name;
  }
  if ($number_drivers > 4) {
    $driver_5_name = $driver_5_first_name;
    $driver_5_name = $driver_5_name.' ';
    if (!empty($driver_5_mi)) {
      $driver_5_name = $driver_5_name.$driver_1_mi;
      $driver_5_name = $driver_5_name.' ';
    }
    $driver_5_name = $driver_5_name.$driver_5_last_name;
  }
  $to = 'jim@independent-micro.com';
  $subject = 'Request for auto quote from website';
  $message = 'Customer Name:      '.$driver_1_name."\n";
  $message .= 'Address   :            '.$_POST['driver_1_address_1']."\n";
  $message .= '                    '.$_POST['driver_1_address_2']."\n";
  $message .= 'City:               '.$_POST['driver_1_city']."\n";
  $message .= 'State  :            '.$_POST['driver_1_state']."\n";
  $message .= 'Zip:                '.$_POST['driver_1_zip']."\n\n";
  $message .= 'Residence Status:   '.$_POST['driver_1_residence']."\n";
  $message .= 'Home Phone:         '.$_POST['driver_1_home_phone']."\n";
  $message .= 'Other Phone:        '.$_POST['driver_1_other_phone']."\n";
  $message .= 'Email    :              '.$_POST['driver_1_email']."\n\n";
  $message .= 'Marital Status:     '.$_POST['driver_1_marital_status']."\n";
  $message .= 'Date of Birth:      '.$_POST['driver_1_dob']."\n";
  $message .= 'Soc. Sec Number:    '.$_POST['driver_1_soc_sec']."\n\n";
 
  if ($number_drivers > 1) {
   $message .= 'Second Driver Name:         '.$driver_2_name."\n";
   $message .= 'Marital Status  :              '.$_POST['driver_2_marital_status']."\n";
   $message .= 'Date of Birth  :               '.$_POST['driver_2_dob']."\n";
   $message .= 'Soc. Sec Number:             '.$_POST['driver_2_soc_sec']."\n";
   $message .= 'Relationship to Driver 1:    '.$_POST['driver_2_relationship']."\n\n";
  } 
   if ($number_drivers > 2) {
   $message .= 'Third Driver Name:           '.$driver_3_name."\n\n";
   $message .= 'Marital Status:              '.$_POST['driver_3_marital_status']."\n\n";
   $message .= 'Date of Birth:               '.$_POST['driver_3_dob']."\n\n";
   $message .= 'Soc. Sec Number:             '.$_POST['driver_3_soc_sec']."\n\n";
   $message .= 'Relationship to Driver 1:    '.$_POST['driver_3_relationship']."\n\n\n";
  } 
   if ($number_drivers > 3) {
   $message .= 'Second Driver Name:          '.$driver_4_name."\n\n";
   $message .= 'Marital Status:              '.$_POST['driver_4_marital_status']."\n\n";
   $message .= 'Date of Birth:               '.$_POST['driver_4_dob']."\n\n";
   $message .= 'Soc. Sec Number:             '.$_POST['driver_4_soc_sec']."\n\n";
   $message .= 'Relationship to Driver 1:    '.$_POST['driver_4_relationship']."\n\n\n";
  } 
  if ($number_drivers > 4) {
   $message .= 'Second Driver Name:          '.$driver_5_name."\n\n";
   $message .= 'Marital Status:              '.$_POST['driver_5_marital_status']."\n\n";
   $message .= 'Date of Birth:               '.$_POST['driver_5_dob']."\n\n";
   $message .= 'Soc. Sec Number:             '.$_POST['driver_5_soc_sec']."\n\n";
   $message .= 'Relationship to Driver 1:    '.$_POST['driver_5_relationship']."\n\n\n";
  } 
  $message .= 'End of Info   ';
  mail($to, $subject, $message);
	
  // go to step two
 // header('Location: http://www.example.org/');
 header('Location: http://www.bobtracyinsurance.com/btracy_thank_you.php');
 
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Get free auto insurance quotes at Bob Tracy Insurance</title>
<link href="CssFiles/tracy.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.left_info {font-size: small}
.style1 {font-size: 14px}
.style6 {font-size: 12px}
#auto2_main {position:absolute;
	width:713px;
	height:399px;
	z-index:1;
	left: 175px;
	top: 51px;
}
#menu {
	position:absolute;
	width:143px;
	<?php if ($number_drivers == 1) { ?>
	height:690px;
	<?php } ?>
	<?php if ($number_drivers == 2) { ?>
	height:960px;
	<?php } ?>
	<?php if ($number_drivers == 3) { ?>
	height:1230px;
	<?php } ?>
	<?php if ($number_drivers == 4) { ?>
	height:1500px;
	<?php } ?>
	<?php if ($number_drivers == 5) { ?>
	height:1770px;
	<?php } ?>
	
	z-index:1;
	left: 3px;
	top: 100px;
	background-color: #547E29;
}
.style7 {font-size: xx-small}
-->
</style>
</head>

<body>
<div id="auto2_main">
  <table width="700" border="0" align="center" cellpadding="0">
    <tr>
      <td><form id="auto_one" name="auto_one" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
        <table width="680" border="0" align="center" cellpadding="0">
          <tr>
            <td colspan="3"><div align="center">
              <h3>Step 2 of 2 </h3>
            </div></td>
          </tr>
          <tr>
            <td width="198"><h3>Driver Information  </h3></td>
            <td width="59">&nbsp;</td>
            <td width="415">(* =Required fields) </td>
          </tr>
          <tr>
            <td height="15">&nbsp;</td>
            <td>&nbsp;</td>
            <td class="style1">Primary Driver </td>
          </tr>
          <tr>
            <td class="style1">First Name: </td>
            <td>&nbsp;</td>
            <td><span class="left_info">
              <input name="driver_1_first_name" type="text" id="driver_1_first_name" size="15" maxlength="25" />
              *</span></td>
          </tr>
          <tr>
            <td class="style1">Middle Initial: <span class="style6"></span> </td>
            <td>&nbsp;</td>
            <td><input name="driver_1_mi" type="text" id="driver_1_mi" size="2" maxlength="1" /></td>
          </tr>
          <tr>
            <td class="style1">Last Name: </td>
            <td>&nbsp;</td>
            <td><input name="driver_1_last_name" type="text" id="driver_1_last_name" size="25" maxlength="50" />
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="left_info">Address:</td>
            <td>&nbsp;</td>
            <td><input name="driver_1_address_1" type="text" id="driver_1_address_1" size="30" maxlength="50" />
              <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td><input name="driver_1_address_2" type="text" id="driver_1_address_2" size="30" maxlength="50" /></td>
          </tr>
          <tr>
            <td class="style1">City: </td>
            <td>&nbsp;</td>
            <td><span class="left_info">
              <input name="driver_1_city" type="text" id="driver_1_city" size="30" maxlength="50" />
              *</span></td>
          </tr>
          <tr>
            <td class="style1">State:</td>
            <td>&nbsp;</td>
            <td><input name="driver_1_state" type="text" id="driver_1_state" size="5" maxlength="2" />
              <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td class="style1">Zip:</td>
            <td>&nbsp;</td>
            <td><span class="left_info">
              <input name="driver_1_zip" type="text" id="driver_1_zip" size="10" maxlength="10" />
              *</span></td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">Residence Status </td>
            <td>&nbsp;</td>
            <td><select name="driver_1_residence" id="driver_1_residence">
              <option value="None Selected">Please Select</option>
              <option value="I own my home">I own my home</option>
              <option value="I own my mobile home">I own my mobile home</option>
              <option value="I rent">I rent</option>
              <option value="I live with my parents">I live with my parents</option>
              <option value="Other">Other</option>
            </select>            </td>
          </tr>
          <tr>
            <td class="style1">Home Phone:  </td>
            <td>&nbsp;</td>
            <td>              <input name="driver_1_home_phone" type="text" id="driver_1_home_phone" size="12" maxlength="12" />
              Ex: 724-555-1212 *</td>
          </tr>
          <tr>
            <td class="style1">Other Phone: </td>
            <td>&nbsp;</td>
            <td><input name="driver_1_other_phone" type="text" id="driver_1_other_phone" size="12" maxlength="12" />
              Ex: 724-555-1212</td>
          </tr>
          <tr>
            <td class="style1">Email:</td>
            <td>&nbsp;</td>
            <td><input name="driver_1_email" type="text" id="driver_1_email" size="50" maxlength="100" /></td>
          </tr>
          <tr>
            <td class="style1">Marital Status: </td>
            <td>&nbsp;</td>
            <td><select name="driver_1_marital_status" id="driver_1_marital_status">
              <option value="None selected">Please Select</option>
              <option value="Single">Single</option>
              <option value="Married">Married</option>
              <option value="Divorced">Divorced</option>
              <option value="Separated">Separated</option>
              <option value="Widowed">Widowed</option>
            </select>
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">Date of Birth: </td>
            <td>&nbsp;</td>
            <td><input name="driver_1_dob" type="text" id="driver_1_dob" size="10" maxlength="10" />
              Ex: MM/DD/YYYY<span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">Soc Sec Number: </td>
            <td>&nbsp;</td>
            <td><input name="driver_1_soc_sec" type="text" id="driver_1_soc_sec" size="11" maxlength="11" />
              Ex: 123-45-6789 <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
		<?PHP
		  if ($number_drivers > 1) { ?>
        <table width="682" border="0" align="center" cellpadding="0" id="driver_2">
          <tr>
            <td width="213" height="15">&nbsp;</td>
            <td width="40">&nbsp;</td>
            <td width="421" class="style1">Second Driver </td>
          </tr>
          <tr>
            <td class="style1">First Name: </td>
            <td>&nbsp;</td>
            <td><span class="left_info">
              <input name="driver_2_first_name" type="text" id="driver_2_first_name" size="15" maxlength="25" />
              *</span></td>
          </tr>
          <tr>
            <td class="style1">Middle Initial: <span class="style6"></span> </td>
            <td>&nbsp;</td>
            <td><input name="driver_2_mi" type="text" id="driver_2_mi" size="2" maxlength="1" /></td>
          </tr>
          <tr>
            <td class="style1">Last Name: </td>
            <td>&nbsp;</td>
            <td><input name="driver_2_last_name" type="text" id="driver_2_last_name" size="25" maxlength="50" />
              <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">Marital Status: </td>
            <td>&nbsp;</td>
            <td><select name="driver_2_marital_status" id="driver_2_marital_status">
              <option value="None selected">Please Select</option>
              <option value="Single">Single</option>
              <option value="Married">Married</option>
              <option value="Divorced">Divorced</option>
              <option value="Separated">Separated</option>
              <option value="Widowed">Widowed</option>
            </select>
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">Date of Birth: </td>
            <td>&nbsp;</td>
            <td><input name="driver_2_dob" type="text" id="driver_2_dob" size="10" maxlength="10" />
              Ex: MM/DD/YYYY <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td class="style1">Soc Sec Number: </td>
            <td>&nbsp;</td>
            <td><input name="driver_2_soc_sec" type="text" id="driver_2_soc_sec" size="11" maxlength="11" />
              Ex: 123-45-6789 <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">Relationship to Primary Driver </td>
            <td>&nbsp;</td>
            <td><select name="driver_2_relationship" id="driver_2_relationship">
              <option value="None selected">Please Select</option>
              <option value="Spouse">Spouse</option>
              <option value="Child">Child</option>
              <option value="Parent">Parent</option>
              <option value="Other">Other</option>
            </select>
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
		</table>
		<?PHP } ?>
		<?PHP
		  if ($number_drivers > 2) { ?>
		
        <table width="682" border="0" align="center" cellpadding="0" id="driver_3">
          <tr>
            <td width="214" height="15">&nbsp;</td>
            <td width="41">&nbsp;</td>
            <td width="419" class="style1">Third Driver </td>
          </tr>
          <tr>
            <td class="style1">First Name: </td>
            <td>&nbsp;</td>
            <td><span class="left_info">
              <input name="driver_3_first_name" type="text" id="driver_3_first_name" size="15" maxlength="25" />
              *</span></td>
          </tr>
          <tr>
            <td class="style1">Middle Initial: <span class="style6"></span> </td>
            <td>&nbsp;</td>
            <td><input name="driver_3_mi" type="text" id="driver_3_mi" size="2" maxlength="1" /></td>
          </tr>
          <tr>
            <td class="style1">Last Name: </td>
            <td>&nbsp;</td>
            <td><input name="driver_3_last_name" type="text" id="driver_3_last_name" size="25" maxlength="50" />
              <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">Marital Status: </td>
            <td>&nbsp;</td>
            <td><select name="driver_3_marital_status" id="driver_3_marital_status">
              <option value="None selected">Please Select</option>
              <option value="Single">Single</option>
              <option value="Married">Married</option>
              <option value="Divorced">Divorced</option>
              <option value="Separated">Separated</option>
              <option value="Widowed">Widowed</option>
            </select>
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">Date of Birth: </td>
            <td>&nbsp;</td>
            <td><input name="driver_3_dob" type="text" id="driver_3_dob" size="10" maxlength="10" />
              Ex: MM/DD/YYYY <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td class="style1">Soc Sec Number: </td>
            <td>&nbsp;</td>
            <td><input name="driver_3_soc_sec" type="text" id="driver_3_soc_sec" size="11" maxlength="11" />
              Ex: 123-45-6789 <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">Relationship to Primary Driver </td>
            <td>&nbsp;</td>
            <td><select name="driver_3_relationship" id="driver_3_relationship">
              <option value="None selected">Please Select</option>
              <option value="Spouse">Spouse</option>
              <option value="Child">Child</option>
              <option value="Parent">Parent</option>
              <option value="Other">Other</option>
            </select>
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
		</table>
		<?PHP } ?>
		<?PHP
		  if ($number_drivers > 3) { ?>
        <table width="682" border="0" align="center" cellpadding="0" id="driver_4">
          <tr>
            <td width="216" height="15">&nbsp;</td>
            <td width="41">&nbsp;</td>
            <td width="417" class="style1">Fourth Driver </td>
          </tr>
          <tr>
            <td class="style1">First Name: </td>
            <td>&nbsp;</td>
            <td><span class="left_info">
              <input name="driver_4_first_name" type="text" id="driver_4_first_name" size="15" maxlength="25" />
              *</span></td>
          </tr>
          <tr>
            <td class="style1">Middle Initial: <span class="style6"></span> </td>
            <td>&nbsp;</td>
            <td><input name="driver_4_mi" type="text" id="driver_4_mi" size="2" maxlength="1" /></td>
          </tr>
          <tr>
            <td class="style1">Last Name: </td>
            <td>&nbsp;</td>
            <td><input name="driver_4_last_name" type="text" id="driver_4_last_name" size="25" maxlength="50" />
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">Marital Status: </td>
            <td>&nbsp;</td>
            <td><select name="driver_4_marital_status" id="driver_4_marital_status">
              <option value="None selected">Please Select</option>
              <option value="Single">Single</option>
              <option value="Married">Married</option>
              <option value="Divorced">Divorced</option>
              <option value="Separated">Separated</option>
              <option value="Widowed">Widowed</option>
            </select>
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">Date of Birth: </td>
            <td>&nbsp;</td>
            <td><input name="driver_4_dob" type="text" id="driver_4_dob" size="10" maxlength="10" />
              Ex: MM/DD/YYYY <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td class="style1">Soc Sec Number: </td>
            <td>&nbsp;</td>
            <td><input name="driver_4_soc_sec" type="text" id="driver_4_soc_sec" size="11" maxlength="11" />
              Ex: 123-45-6789 <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">Relationship to Primary Driver </td>
            <td>&nbsp;</td>
            <td><select name="driver_4_relationship" id="driver_4_relationship">
              <option value="None selected">Please Select</option>
              <option value="Spouse">Spouse</option>
              <option value="Child">Child</option>
              <option value="Parent">Parent</option>
              <option value="Other">Other</option>
            </select>
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
		</table>
		<?PHP } ?>
		<?PHP
		  if ($number_drivers > 4) { ?>
		
        <table width="682" border="0" align="center" cellpadding="0" id="driver_5">
          <tr>
            <td width="216" height="15">&nbsp;</td>
            <td width="42">&nbsp;</td>
            <td width="416" class="style1">Fifth Driver </td>
          </tr>
          <tr>
            <td class="style1">First Name: </td>
            <td>&nbsp;</td>
            <td><span class="left_info">
              <input name="driver_5_first_name" type="text" id="driver_5_first_name" size="15" maxlength="25" />
              *</span></td>
          </tr>
          <tr>
            <td class="style1">Middle Initial: <span class="style6"></span> </td>
            <td>&nbsp;</td>
            <td><input name="driver_5_mi" type="text" id="driver_5_mi" size="2" maxlength="1" /></td>
          </tr>
          <tr>
            <td class="style1">Last Name: </td>
            <td>&nbsp;</td>
            <td><input name="driver_5_last_name" type="text" id="driver_5_last_name" size="25" maxlength="50" />
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">Marital Status: </td>
            <td>&nbsp;</td>
            <td><select name="driver_5_marital_status" id="driver_5_marital_status">
              <option value="None selected">Please Select</option>
              <option value="Single">Single</option>
              <option value="Married">Married</option>
              <option value="Divorced">Divorced</option>
              <option value="Separated">Separated</option>
              <option value="Widowed">Widowed</option>
            </select>
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">Date of Birth: </td>
            <td>&nbsp;</td>
            <td><input name="driver_5_dob" type="text" id="driver_5_dob" size="10" maxlength="10" />
              Ex: MM/DD/YYYY <span class="left_info">*</span></td>
          </tr>
          <tr>
            <td class="style1">Soc Sec Number: </td>
            <td>&nbsp;</td>
            <td><input name="driver_5_soc_sec" type="text" id="driver_5_soc_sec" size="11" maxlength="11" />
              Ex: 123-45-6789<span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">Relationship to Primary Driver </td>
            <td>&nbsp;</td>
            <td><select name="driver_5_relationship" id="driver_5_relationship">
              <option value="None selected">Please Select</option>
              <option value="Spouse">Spouse</option>
              <option value="Child">Child</option>
              <option value="Parent">Parent</option>
              <option value="Other">Other</option>
            </select>
              <span class="left_info">*</span> </td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
		</table>
		<?PHP } ?>
        <table width="682" border="0" align="center" cellpadding="0" id="sendit">
          <tr>
            <td width="212" class="style1">&nbsp;</td>
            <td width="47">&nbsp;</td>
            <td width="415"><input name="submit_info" type="submit" id="submit_info" value="Submit Information" /></td>
          </tr>
		 </table>		
      </form></td>
    </tr>
  </table>
</div>
<div id="menu">

  <p>
  <p>&nbsp;</p>
	<p>&nbsp;</p>
    <script menumaker>document.write('<scr' + 'ipt src="images/mainmenu1.js">'+'</scr'+'ipt>');/*img src="images/mainmenu1.gif" moduleid="bob tracy (project)\mainmenu1_off.xws"*/</script>
  </p>
  
  <p>&nbsp; </p>
  <table width="140" border="0" cellpadding="0">
    <tr>
      <th width="184" class="whitefont" scope="col"><div align="center" class="left_info"> Bob Tracy Insurance </div></th>
    </tr>
    <tr>
      <td class="whitefont"><div align="center" class="left_info"> 433 State Street</div></td>
    </tr>
    <tr>
      <td class="whitefont"><div align="center" class="left_info"> Beaver, PA&nbsp; 15009</div></td>
    </tr>
    <tr>
      <td class="whitefont"><div align="center" class="style1">
        <div align="center"></div>
      </div></td>
    </tr>
    <tr>
      <td class="whitefont"><div align="center" class="left_info"> (724) 728 - 1200</div></td>
    </tr>
    <tr>
      <td class="whitefont">&nbsp;</td>
    </tr>
    <tr>
      <td class="whitefont"><div align="center">Monday thru Friday </div></td>
    </tr>
    <tr>
      <td class="whitefont"><div align="center">8:30 - 4:30 </div></td>
    </tr>
    <tr>
      <td class="left_info"><div align="center" class="whitefont style7">Evenings by appointment </div></td>
    </tr>
  </table>
  <p>&nbsp; </p>
</div>
</body>
</html>

Posted: Thu Jul 26, 2007 10:56 am
by miro_igov
If you use header('Location: http://bobtracyinsurance.com/btracy_auto_quotes_2.php'); how you expect the POST to be not empty? and how exactly you understood that the sessions are not working?

Posted: Thu Jul 26, 2007 11:00 am
by miro_igov
And i don't know what book you read but my suggestion is to throw it into the bin.

This is idiotic:

Code: Select all

if ($number_drivers > 3) {
  $driver_4_first_name = trim($_POST['driver_4_first_name']);
  $driver_4_mi = trim($_POST['driver_4_mi']);
you can use <input name="driver_first_name[]" .... then use forech($_POST['driver_first_name'] $number=>$first_name)

Posted: Thu Jul 26, 2007 11:09 am
by jimdavidson
My understanding on how this works is that when the user fills out the information on the first page and clicks continue to second page, the code stores that info to session variables and sends the user to page two.

How I know it's not working is that if I enter 2 or more drivers on page one then the form on page two will show input fields for the other drivers. and it doesn't.

But if I change that one line of code in page one to...
header('Location: http://localhost/btracy_auto_quotes_2.php');

instead of...
header('Location: http://bobtracyinsurance.com/btracy_auto_quotes_2.php');

then run same two page on my localhost all works fine, the form shows input areas for the other driver info.

Posted: Thu Jul 26, 2007 11:29 am
by miro_igov
OMG that is really fun :lol: :lol: :lol:

Do you expect that creating a session on server A (your localhost) will create the same session on server B (bobtracy site)?

Posted: Thu Jul 26, 2007 11:45 am
by jimdavidson
No, I'm saying when I run both page one and page two on the localhost they work, the session variables go to page two. When I run them both off of the remote they don't.

By the way the main session variable from page one needed to run page two is $_SESSION['number_divers'].

Posted: Thu Jul 26, 2007 12:10 pm
by John Cartwright
Moved to PHP-Code

Posted: Thu Jul 26, 2007 12:30 pm
by xdallen
From my experience, if you make user of header(), sometimes the server has not enough time to save down the session data and another request from the client-side has already been initiated.

For my advice, I think you may add a function called session_write_close() before calling header().

This is for your reference.
http://www.php.net/manual/en/function.s ... -close.php

Posted: Thu Jul 26, 2007 12:41 pm
by jimdavidson
It's already in the code, I have a feeling that the info in page one is not getting stored to the session variables from the post. Again, I new at php, could someone tell me if I'm doing that part correctly. Here's that section again

Code: Select all

if (array_key_exists('step_two', $_POST)) {
// continue to step two button clicked
  // remove escape characters from POST array
  if (get_magic_quotes_gpc()) {
    function stripslashes_deep($value) {
      $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
      return $value;
    }
    $_POST = array_map('stripslashes_deep', $_POST);
  } // end magic quotes
  // get input and store to session variables

  $_SESSION['number_divers'] = $_POST['number_drivers'];  
  $_SESSION['number_vehicles'] = $_POST['number_vehicles'];  
  $_SESSION['current_insurance'] = $_POST['current_insurance'];  
  $_SESSION['current_company'] = $_POST['current_company'];  
  $_SESSION['refferal'] = $_POST['refferal']; 
  // go to step two
 session_write_close();  
// depending on wheather I'm testing or live as to which header I use
// header('Location: http://localhost/btracy_auto_quotes_2.php');
header('Location: http://bobtracyinsurance.com/btracy_auto_quotes_2.php');
 exit;

Posted: Thu Jul 26, 2007 1:55 pm
by RobertGonzalez
Test to see that sessions are working to begin with. Try this...
session-test-page1.php

Code: Select all

<?php
//Session start
session_start();
 
//Set session vars
if (!isset($_SESSION['username']) && !isset($_SESSION['password']))
{
    $_SESSION['username'] = 'testusername';
    $_SESSION['password'] = 'testpassword';
    //header('Location: session-test-page2.php');
    //exit;
}
else
{
    // Quick error checking
    echo '<pre>'; var_dump($_SESSION); echo '< /pre>';
    echo '<p>You user name is already set to ' . $_SESSION['username'] . '</p>';
    echo '<p>And your password is already set to ' . $_SESSION['password'] . '</p>';
}
 
if (isset($_GET['clear']))
{
    // Unset all of the session variables.
    $_SESSION = array();
 
    // If it's desired to kill the session, also delete the session cookie.
    // Note: This will destroy the session, and not just the session data!
    if (isset($_COOKIE[session_name()])) {
        setcookie(session_name(), '', time()-42000, '/');
    }
 
    // Finally, destroy the session.
    session_destroy();
 
    echo '<p>Even though you see the information above, the session has already been terminated. 
    <a href="' . basename($_SERVER['SCRIPT_FILENAME']) . '">Refresh the page</a> and you will see nothing as the page sets the session vars again.</p>';
}
 
echo '<p><a href="session-test-page2.php">Click here for page 2</a></p>';
echo '<p><a href="?clear=true">Click here to clear the session data</a></p>';
?>
session-test-page2.php:

Code: Select all

<?php
//Session start
session_start();
 
// Quick error checking
echo '<pre>'; var_dump($_SESSION); echo '< /pre>';
 
// Echo session vars
echo '<p>You user name is ' . $_SESSION['username'] . '</p>';
echo '<p>And your password is ' . $_SESSION['password'] . '</p>';
 
echo '<a href="session-test-page1.php">Click here to go back to page 1</a>';
?>
I have posted about this several times in the past. I even wrote a blog post about it.

Posted: Thu Jul 26, 2007 3:29 pm
by miro_igov
xdallen wrote:From my experience, if you make user of header(), sometimes the server has not enough time to save down the session data and another request from the client-side has already been initiated.

For my advice, I think you may add a function called session_write_close() before calling header().

This is for your reference.
http://www.php.net/manual/en/function.s ... -close.php
:lol: :lol:

that is if you call header() without to exit the process after it.

Posted: Fri Jul 27, 2007 8:22 am
by jimdavidson
Gee whiz guys, I said I was new to this, you could have been a little forgiving. Idiotic, couldn't you have said poorly written, or something a little kinder?

Anyway thanks for the suggestions I'll give them a shot.

Posted: Fri Jul 27, 2007 9:03 am
by superdezign
jimdavidson wrote:Gee whiz guys, I said I was new to this, you could have been a little forgiving. Idiotic, couldn't you have said poorly written, or something a little kinder?

Anyway thanks for the suggestions I'll give them a shot.
Maybe it was idiotic... A lack of knowledge constitutes being idiotic. Don't worry though, it wasn't an attack on you, just the coding method that you used. As time goes by, everything will start falling into place as long as you put in the effort to learn both the right way and the wrong way and what makes them so.