what do you reckon of this?
only prob is that at the bottom after the stop all the code is all black..
Code: Select all
<?php
#******************************************************************************
# This function prints a blank purchase form.
#******************************************************************************
function print_form()
{
session_start();
// This page contains the connection routine for the
// database as well as getting the ID of the cart, etc
$db = mysql_pconnect('', '', '') or die ("Could not connect to database");
if (!$db)
{
echo 'Error: Could not connect to database. Please try again laterrrrrr.';
exit;
}
mysql_select_db('models') or die ("Could not select database!");
function ConnectToDb($server, $user, $pass, $database)
{
// Connect to the database and return
// true/false depending on whether or
// not a connection could be made.
$s = @mysql_connect($server, $user, $pass);
$d = @mysql_select_db($database, $s);
if(!$s || !$d)
return false;
else
return true;
}
function GetCartId()
{
// This function will generate an encrypted string and
// will set it as a cookie using set_cookie. This will
// also be used as the cookieId field in the cart table
if(isset($_COOKIE["cartId"]))
{
return $_COOKIE["cartId"];
}
else
{
// There is no cookie set. We will set the cookie
// and return the value of the users session ID
setcookie("cartId", session_id(), time() + ((3600 * 24) * 30));
return session_id();
}
}
$db = mysql_pconnect('db.iserve.net.nz', 'chris', 'cessna') or die ("Could not connect to database");
if (!$db)
{
echo 'Error: Could not connect to database. Please try again laterrrrrr.';
exit;
}
mysql_select_db('models') or die ("Could not select database!");
$totalCost = 0;
$shipping = 0;
$result = mysql_query("select * from cart inner join planes on cart.itemId = planes.itemId where cart.cookieId = '" . GetCartId() . "' order by planes.P_Name asc");
$C_Freight=$_POST['C_Freight'];
if ($C_Freight == 'North Island New Zealand')
{
$shipping = 10;
$totalCost = $totalCost + $shipping;
}
if ($C_Freight == 'South Island New Zealand')
{
$shipping = 20;
$totalCost = $totalCost + $shipping;
}
else
{
$shipping = 30;
$totalCost = $totalCost + $shipping;
}
echo <<<STOP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Model Aircraft</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="all">
@import url(Payment%20Express/model.css);
</style>
<script type="text/javascript">
<!--
function getWindowHeight() {
var windowHeight = 0;
if (typeof(window.innerHeight) == 'number') {
windowHeight = window.innerHeight;
}
else {
if (document.documentElement && document.documentElement.clientHeight) {
windowHeight = document.documentElement.clientHeight;
}
else {
if (document.body && document.body.clientHeight) {
windowHeight = document.body.clientHeight;
}
}
}
return windowHeight;
}
function setFooter() {
if (document.getElementById) {
var windowHeight = getWindowHeight();
if (windowHeight > 0) {
var contentHeight = document.getElementById('container').offsetHeight;
var footerElement = document.getElementById('footer');
var footerHeight = footerElement.offsetHeight;
if (windowHeight - (contentHeight + footerHeight) >= 0) {
footerElement.style.position = 'relative';
footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
}
else {
footerElement.style.position = 'static';
}
}
}
}
window.onload = function() {
setFooter();
}
window.onresize = function() {
setFooter();
}
//-->
</script>
</head>
<body>
<div id="container"><h1>Models</h1>
<!-- Begin Nav center -->
<div id="navcenter">
<ul>
<li><a href="/index.php">Home</a></li>
<li><a href="/about.php">About</a></li>
<li><a href="/contact.php">Contact</a></li>
<li><a href="/links.php">Aviation Links</a></li>
<li><a href="/cart.php">Shopping Cart</a></li>
</ul>
</div>
<!-- End Nav Center -->
<!-- Begin LEFT -->
<div id="left">
<!-- Begin navigation -->
<div id="navcontainer">
<ul>
<li><a href="#">1st Flight</a></li>
<li><a href="#">Commercial</a></li>
<li><a href="#">Famous Air Races</a></li>
<li><a href="#">General Aviation</a></li>
<li><a href="#">Helicopters</a></li>
<li><a href="#">Intl Military</a></li>
<li><a href="#">NASA Craft</a></li>
<li><a href="#">Seaplanes</a></li>
<li><a href="#">US Army</a></li>
<li><a href="#">US Coastguard</a></li>
<li><a href="#">US Marine Coprps</a></li>
<li><a href="#">US Navy</a></li>
<li><a href="#">USAF Fighters</a></li>
<li><a href="#">USAF Piston</a></li>
<li><a href="#">Vintage Commercial</a></li>
<li><a href="#">Vintage Transport</a></li>
<li><a href="#">WWI Aircraft</a></li>
<li><a href="#">WWI Bombers</a></li>
<li><a href="#">WWII Fighters</a></li>
</ul>
</div>
<!-- End navigation -->
</div>
<!-- End LEFT -->
<!-- Begin Content -->
<div id="content">
<form method="post">
<h2>Summary</h2>
<p class="text">
<table width="500">
<!--DWLayoutTable-->
<tr>
<td width="80" height="21" valign="top">First Name:</td>
<td width="135" valign="top"><?php echo $C_First=$_POST['C_First']; ?></td>
<td width="91" valign="top">Last Name: </td>
<td width="172" valign="top"><?php echo $C_Last=$_POST['C_Last']; ?></td>
</tr>
<tr>
<td height="21" valign="top">Email:</td>
<td valign="top"><?php echo $C_Email=$_POST['C_Email']; ?></td>
<td valign="top">Phone:</td>
<td valign="top"><?php echo $C_Phone=$_POST['C_Phone']; ?></td>
</tr>
<tr>
<td height="21" valign="top">Address 1:</td>
<td valign="top"><?php echo $C_Address1=$_POST['C_Address1']; ?></td>
<td valign="top">Address 2:</td>
<td valign="top"><?php echo $C_Address2=$_POST['C_Address2']; ?></td>
</tr>
<tr>
<td height="21" valign="top">Country:</td>
<td valign="top"><?php echo $C_Country=$_POST['C_Country']; ?></td>
<td valign="top">City:</td>
<td valign="top"><?php echo $C_City=$_POST['C_City']; ?></td>
</tr>
</table>
<br />
<table width="450">
<tr>
<td width ="100">Select Zone:</td>
<td><?php echo $C_Freight; ?></td>
</tr>
</table>
<br />
<table width="500">
<!--DWLayoutTable-->
<tr>
<td width="91" height="40" valign="top"><strong>Aircraft</strong></td>
<td width="105" valign="top"><strong>Name</strong></td>
<td colspan="2" valign="top"><strong>Price Ea</strong></td>
<td width="51" align="left" valign="top"><strong>Qty</strong></td>
<td colspan="2" valign="top"><strong>Sub-Total</strong></td>
</tr>
<!--DWLayoutTable-->
<?
while($row = mysql_fetch_array($result))
{
// Increment the total cost of all planes
$totalCost += ($row["qty"] * $row["P_Price"]);
?>
<tr>
<td height="64" valign="top"><img src=http://www.modelaircraft.co.nz/Pics/<?php echo $row["P_Stock"];?>.jpg alt="image of plane" width="82" height="62" class="planeimage" /></td>
<td><?php echo $row["P_Name"]; ?></td>
<td colspan="2" valign="middle">$<?php echo number_format($row["P_Price"], 2, ".", ","); ?></td>
<td align="left" valign="middle"><?php echo $row["qty"]; ?></td>
<td colspan="2" valign="middle"> $
<?php $row["subtotal"] = ($row["qty"] * $row["P_Price"]); echo number_format($row["subtotal"], 2, ".", ","); ?>
</td>
</tr>
<?
} //You have to have this read as php
?>
<!--DWLayoutTable-->
<tr>
<td height="21" colspan="6" valign="top"><hr size="1" color="#666666" NOSHADE /></td>
<td width="66" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td height="30" colspan="3" valign="center"><!--DWLayoutEmptyCell--> </td>
<td colspan="2" valign="top"><strong>Freight:</strong> </td>
<td colspan="2" valign="top">$<?php echo number_format($shipping, 2, ".", ","); ?>
</td>
</tr>
<tr>
<td height="30" colspan="3" valign="top"><!--DWLayoutEmptyCell--> </td>
<td colspan="2" valign="top"><strong>Total: </strong></td>
<td colspan="2" valign="top">$<?php echo number_format($totalCost, 2, ".", ","); ?>
</td>
</tr>
<tr>
<td height="5"></td>
<td></td>
<td width="45"></td>
<td width="45"></td>
<td></td>
<td width="54"></td>
<td></td>
</tr>
</table>
<p class = "text">
<input name="Submit" type="submit" value="Submit" class="button"/>
</p>
</p>
</form>
</div>
<!-- End Content -->
</div>
<!-- Begin Footer -->
<div id="footer">
<h3>copyright © 2004 Model Aircraft</h3>
</div>
<!-- End Footer -->
</body>
</html>
STOP;
}
#******************************************************************************
# This function formats data into a request and redirects to the
# Payments Page.
#******************************************************************************
?>