Guys, I need some help badly
I am workin on a site (supposed to be DONE on monday!) that includes a VERY simple shopping cart. It takes variables from one (ok 7, but they are coded the same, so I am only including one of them) page and then submits them to another page which requires them to login to the site and then submits their order to the database. My problem is with the second page. When I DON'T have the log-in script included, it works fine, but when I DO, it doesn't add the order to the database. It adds a line but all off the "package colums" (that include the number of items the customer wants) are still 0's! can anyone help me?
here is the code....
the first page (that SENDS the variables from a simple form.)
PHP Code:
<html>
<head>
<title>Lewright Meats</title>
<?php
@include("http://www.lewrightmeats.biz/includes/header.php")
?>
<p align="right">
<a href="/packages/"><font class="text14" color="1D6B21">Packages</font></a><br>
<a href="/packages/cart.php"><font class="text14" color="1D6B21">My Cart</font></a>
</p>
<font class="text24"><b>
Package 1
</b></font>
<br>
<br>
<img src="/images/package1.jpg"><br><br>
<br>
<font class="text18" color="1D6B21"><b>Package includes:</b></font><br>
<font class="text14">
<ul type="circle">
<li>Our award winning ham, cooked to perfection over burning Hickory logs, with no water added.</li>
</ul>
</font>
<br><br>
<div id="orderform">
<font class="text18" color="990033">Quantity Requested:</font>
<font class="text14">
<form action="/packages/order.php" method="post">
8-9lb. Hams @ 40.30 <input name="onea" maxlength="2" size="2"><br>
9-10lb. Hams @ 44.90 <input name="oneb" maxlength="2" size="2"><br>
10-11lb. Hams @ 49.00 <input name="onec" maxlength="2" size="2"><br>
11-12lb. Hams @ 52.10 <input name="oned" maxlength="2" size="2"><br>
<br><br>
<input type=submit name="submitorder" value="submit">
</form>
</div>
</font>
<?php
@include("http://www.lewrightmeats.biz/includes/footer.php")
?>
the second page (the script that is makes them log-in and is SUPPOSED to add their order to the database...which it isn't exactly doing)
PHP Code:
<html>
<head>
<title>Lewright Meats</title>
<?php
@include("http://www.lewrightmeats.biz/includes/header.php")
?>
<?php
$dbhost = "localhost";
$dbuser = "jlewrigh_pages";
$dbpass = "password";
function dbConnect($db="jlewrigh_orders") {
global $dbhost, $dbuser, $dbpass;
$dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
or die("The site database appears to be down.");
if ($db!="" and !@mysql_select_db($db))
die("The site database is unavailable.");
return $dbcnx;
}
if(!isset($email)) {
?>
<html>
<head>
<title> Please Log In</title>
</head>
<body>
<h1> To place an order you need to log In </h1>
<p class="text16">Please enter your username and password below. If you do you have an account, please <a href="/packages/newcust.php" target="_blank">sign up here</a></p>
<p><form method="post" action="http://www.lewrightmeats.biz/packages/order.php">
E-mail address: <input type="text" name="email" size="30"><br>
Password: <input type="password" name="pwd" SIZE="20"><br>
<input type="submit" value="Log in">
</form></p>
</body>
</html>
<?php
exit;
}
dbConnect("jlewrigh_orders");
$sql = "select cust from customers where email = '$email' and password = PASSWORD('$pwd')";
$result = mysql_query($sql);
if (!$result) {
error("A database error occurred while checking your ".
"login details.\\nIf this error persists, please ".
"contact [email]webmaster@lewrightmeats.biz[/email]");
}
if (mysql_num_rows($result) == 0) {
$email="";
$pwd="";
?>
<html>
<head>
<title> please re-enter your login details </title>
</head>
<body>
<p class="text16">Your user ID or password is incorrect. To try logging in again, click <a href="<?=$PHP_SELF?>">here</a>.</p>
</body>
</html>
<?php
exit;
}
while($currow= mysql_fetch_array($result)) {
$cust = $currow["cust"];
}
$dbcnx = @mysql_connect("localhost", "jlewrigh_pages", "password");
if (!$dbcnx) { echo( "<P>Unable to connect to the database server at this time.</P>" ); exit();}
mysql_select_db("jlewrigh_orders", $dbcnx);
$sql2 = "insert into packages set " . "cust='$cust', " . "onea='$onea'," . "oneb='$oneb'," . "onec='$onec'," . "oned='$oned'," . "two='$two'," . "three='$three'," . "four='$four'," . "five='$five'," . "six='$six'," . "seven='$seven'";
if (mysql_query($sql2)) { echo("<p class='text20'>The package(s) have been added to your cart. What do you want to do now?</p><p class='text16'>--Go back to the <a href='/packages/'>packages page</a><br>--Take me to my <a href=/packages/cart.php>cart</a> to check out</P>"); } else { echo("<P class='text16'>Error adding package: " . mysql_error() . " Please e-mail the <a href='mailto:webmaster@lewrightmeats.biz'>webmaster@lewrightmeats.biz</a> to let us know</P>"); }
?>
<?php
@include("http://www.lewrightmeats.biz/includes/footer.php")
?>
Any help would be GREATLY appreciated!
Darrin
P.S. to "log in" you can use
e-mail address:email
passwordass
or you can sign up for an accout if you're willing, I will clear the database before we actually start using the site so you can setup whatever account(s) you need because they will be gone as soon as I fix this anyways.


LinkBack URL
About LinkBacks
ass



Reply With Quote


Bookmarks