Why are session variables not passing to next page
Posted: Thu Jul 26, 2007 10:22 am
Everah | Please use
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 codeCode: 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"> </td>
<td width="249"> </td>
</tr>
<tr>
<td height="15"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="style1">How many drivers are in your household? </td>
<td> </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> <span class="style6"> * Include yourself, your spouse, anyone of driving age in your household, and all other drivers of your vehicles.</span> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="style1">How many vehicles are you insuring? </td>
<td> </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"> * If zero, the remaining questions are optional </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="style1">Do you currently have auto insurance? </td>
<td> </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> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="style1">What
insurance company are you currently insured with, or previously insured
with?</td>
<td> </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> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="style1">How did you hear about us? </td>
<td> </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> </td>
<td> </td>
<td> </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"> </td>
<td width="228"> </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> </p>
<div id="menu">
<p>
<p> </p>
<p> </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> </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 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"> </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> </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]