Hello:
I could use some guidance or help. This is what I’m trying to accomplish. I want to store a persons billing and shipping information in a table.
I have a form where the person enters their billing info. If the shipping info is the same as the billing info, they can check a checkbox.
When they submit the form, the billing info and shipping info appear. In addition, there is another form where they enter other information.
When they submit this form, the billing and shipping info does not come across.
How do I pass form variables from the first script to the third script? I am using sessions. The data passes from script 1 to script 2 but the data does not pass from script 2 to script 3.
I pasted the code for script 2 and 3 since script 1 is basically a form. Though, I will paste the line for the checkbox from this script.
Thank you in advance.
Script 1 – entry form with checkbox
[code]
<tr>
<td width=”109″ height=”20″>
<div align=”left”><font face=”Verdana” size=”1″>If same as Billing:</font></div>
</td>
<td width=”156″ height=”20″>
<font face=”Verdana”>
<input type=”checkbox” name=”same”></font><font size=”2″ face=”Verdana”>
</font>
</td>
</tr>
Script 2 – verifies info and processes another form
[code]
<?php
session_start();
//connect to the database
$conn = mysql_connect(“xx”, “xx”, “xx”)
or die (mysql_error());
mysql_select_db(“xx”);
if ($_POST[‘same’] == ‘on’) {
$_POST[‘shipfirst’] = $_POST[‘firstname’];
$_POST[‘shiplast’] = $_POST[‘lastname’];
$_POST[‘shipadd1’] = $_POST[‘add1’];
$_POST[‘shipadd2’] = $_POST[‘add2’];
$_POST[‘shipcity’] = $_POST[‘city’];
$_POST[‘shipstate’] = $_POST[‘state’];
$_POST[‘shipzip’] = $_POST[‘zip’];
$_POST[‘shipphone’] = $_POST[‘phone’];
$_POST[‘shipemail’] = $_POST[’email’];
}
?>
<html>
<head>
<title>Step 2 of 3 – Verify Order Accuracy</title>
</head>
<body>
Step 1 – Please Enter Billing and Shipping Information<br>
<strong>Step 2 – Please Verify Accuracy and Make Any Necessary
Changes</strong><br>
Step 3 – Order Confirmation and Receipt<br>
<form method=”post” action=”echo.php”>
<table border=”0″ cellpadding=”0″ cellspacing=”0″ width=787>
<tr>
<td width=358><b><font size=2 face=Verdana>Bill to:</font></b></td>
<td width=419><b><font size=2 face=Verdana>Ship to:</font></b></td>
</tr>
<tr>
<td width=358><font size=2 face=Verdana><? echo “$_POST[firstname] $_POST[lastname]”; ?></font></td>
<td width=358><font size=2 face=Verdana><? echo “$_POST[firstname] $_POST[lastname]”; ?></font></td>
</tr>
<tr>
<td width=358><font face=”Verdana” size=”2″><? echo “$_POST[add1]”; ?></font></td>
<td width=358><font face=”Verdana” size=”2″><? echo “$_POST[add1]”; ?></font></td>
</tr>
<tr>
<td width=358><font size=2 face=Verdana><? echo “$_POST[add2]”; ?></font></td>
<td width=358><font size=2 face=Verdana><? echo “$_POST[add2]”; ?></font></td>
</tr>
<tr>
<td width=358><font size=2 face=Verdana><? echo “$_POST[city], $_POST[state],
$_POST[zip]”; ?></font></td>
<td width=358><font size=2 face=Verdana><? echo “$_POST[city], $_POST[state],
$_POST[zip]”; ?></font></td>
</tr>
<tr>
<td width=358> </td>
<td width=358> </td>
</tr>
<tr>
<td width=358><font face=”Verdana” size=”2″><? echo “$_POST[phone]”; ?></font></td>
<td width=358><font face=”Verdana” size=”2″><? echo “$_POST[phone]”; ?></font></td>
</tr>
<tr>
<td width=358><font face=”Verdana” size=”2″><? echo “$_POST[email]”; ?></font></td>
<td width=358><font face=”Verdana” size=”2″><? echo “$_POST[email]”; ?></font></td>
</tr>
<tr>
<td width=358> </td>
<td width=419> </td>
</tr>
</table>
<hr>
<?php
$sessid = session_id();
$query = “SELECT * FROM carttemp WHERE carttemp_sess = ‘$sessid'”;
$results = mysql_query($query) or die(mysql_error());
$rows = mysql_num_rows($results);
?>
<table border = “1” cellpadding=”5″>
<tr>
<td>Quantity</td>
<td>Item Code</td>
<td>Name</td>
<td>Color</td>
<td>Price</td>
<td>Extended Price</td>
<td> </td>
<td> </td>
<?php
$total = 0.0;
$ordertotal = 0.0;
while ($row = mysql_fetch_array($results)) {
extract($row);
echo “<tr><td>”;
echo $carttemp_qty;
echo “</td>”;
echo “<td>”;
echo “$carttemp_prodnum”;
echo “</td>”;
echo “<td>”;
echo “$carttemp_prodname”;
echo “</td>”;
echo “<td>”;
echo “$carttemp_color”;
echo “</td>”;
echo “<td>”;
echo “$carttemp_price”;
echo “</td>”;
echo “<td align=”right”>”;
$extprice = $carttemp_price * $carttemp_qty;
$orderextprice = $carttemp_price * $carttemp_qty;
echo number_format($extprice,2);
echo “</td>”;
echo “<td>”;
echo “<a href=”cart.php”>Make Changes to Cart</a>”;
echo “</td>”;
echo “</tr>”;
//add extended price to total
$total = $extprice + $total;
$ordertotal = $orderextprice + $ordertotal;
}
?>
<tr>
<td colspan=”5″ align=”right”>Subtotal:</td>
<td align=”right”> <?php echo number_format($total, 2); ?></td>
<td></td>
<td></td>
</tr>
</table>
<input type=”hidden” name=”ordertotal” value=”<?php echo $ordertotal; ?>”>
<p>
<input type=”submit” name=”Submit” value=”Send Order –>”>
</p>
</form>
</body>
</html>
Finally, the third script which should populate the table with the billing and shipping info and it doesn’t:
[code]
<?php
session_start();
//connect to the database – either include a connection variable file
//or type the following lines:
$connect = mysql_connect(“xx”, “xx”, “xx”)
or die (“Hey loser, check your server connection.”);
mysql_select_db(“xx”);
//Let’s make the variables easy to access in our queries
$firstname = $_POST[‘firstname’];
$lastname = $_POST[‘lastname’];
$firstname = $_POST[‘firstname’];
$add1 = $_POST[‘add1’];
$add2 = $_POST[‘add2’];
$city = $_POST[‘city’];
$state = $_POST[‘state’];
$zip = $_POST[‘zip’];
$phone = $_POST[‘phone’];
$fax = $_POST[‘fax’];
$email = $_POST[’email’];
$shipfirst = $_POST[‘shipfirst’];
$shiplast = $_POST[‘shiplast’];
$shipadd1 = $_POST[‘shipadd1’];
$shipadd2 = $_POST[‘shipadd2’];
$shipcity = $_POST[‘shipcity’];
$shipstate = $_POST[‘shipstate’];
$shipzip = $_POST[‘shipzip’];
$shipstate = $_POST[‘shipstate’];
$shipphone = $_POST[‘shipphone’];
$shipemail = $_POST[‘shipemail’];
$total = $_POST[‘total’];
$sessid = session_id();
$today = date(“Y-m-d”);
//2) Insert Info into ordermain
$query3 = “INSERT INTO ordermain (
ordermain_orderdate, ordermain_custnum,
ordermain_shipfirst, ordermain_shiplast,
ordermain_shipadd1, ordermain_shipadd2,
ordermain_shipcity, ordermain_shipstate,
ordermain_shipzip, ordermain_shipphone,
ordermain_shipemail)
VALUES (
‘$today’,
‘$customers_custnum’,
‘$shipfirst’,
‘$shiplast’,
‘$shipadd1’,
‘$shipadd2’,
‘$shipcity’,
‘$shipstate’,
‘$shipzip’,
‘$shipphone’,
‘$shipemail’)”;
$insert2 = mysql_query($query3) or die (mysql_error());
$orderid = mysql_insert_id();