Posted: Fri Mar 11, 2005 9:54 am
here's a guess.. remove the ******* bits.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
} else {
$get_cart = "select tr.id, inv.name, inv.price, tr.qty from tracking
as tr left join inventory as inv on inv.id = tr.item_id where session_id = '$userses'";
$get_cart_res = mysql_query($get_cart) or die(mysql_error());
$subject = "blah blah blah...";
$message = "Dear $firstname $lastname,
Thank you for ordering at blah.com!
Order Summary:\n";
while ($cart = mysql_fetch_array($get_cart_res)) {
$name = stripslashes($cart['name']);
$price = $cart['price'];
$qty = $cart['qty'];
$message .= "$qty";
}
$message .= "Subtotal: $subtotal
Tax: $tax
Shipping: $shipping
Total: $total
Blah blah blah...";
mail($email, $subject, $message, "From: blah@blah..com\r\n");
header("Location: https://-URL-");
}Code: Select all
<?php
session_start();
header("Cache-control: private");/* IE6 fix */
include('../phpcode/include.php');
$cc_type = $_POST['cc_type'];
$cc_number = $_POST['cc_number'];
$cc_month = $_POST['cc_month'];
$cc_year = $_POST['cc_year'];
$cc_holder = $_POST['cc_holder'];
$cc_type = stripslashes($cc_type);
$cc_number = stripslashes($cc_number);
$cc_month = stripslashes($cc_month);
$cc_year = stripslashes($cc_year);
$cc_holder = stripslashes($cc_holder);
if((!$cc_type) || (!$cc_number) || (!$cc_month) || (!$cc_year) || (!$cc_holder)) {
echo 'You did not submit the following information: <br />';
if(!$cc_type){
echo "Credit card type is a required field. Please enter it below.<br />";
}
if(!$cc_number){
echo "Credit card number is a required field. Please enter it below.<br />";
}
if(!$cc_month){
echo "Card expiration month is a required field. Please enter it below.<br />";
}
if(!$cc_year){
echo "Card expiration year is a required field. Please enter it below.<br />";
}
if(!$cc_holder){
echo "Cardholder name is a required field. Please enter it below.<br />";
}
include 'payment_info.php';
exit();
}
// Assign variables from sessions:
$sesid = $_SESSION["usersession"];
$firstname = $_SESSION["firstnamex"];
$lastname = $_SESSION["lastnamex"];
$email = $_SESSION["emailx"];
$address1 = $_SESSION["address1x"];
$address2 = $_SESSION["address2x"];
$city = $_SESSION["cityx"];
$state = $_SESSION["statex"];
$zip = $_SESSION["zipx"];
$phone = $_SESSION["phonex"];
$subtotal = $_SESSION["subtotalx"];
$tax = $_SESSION["taxx"];
$shipping = $_SESSION["shippingx"];
$total = $_SESSION["totalx"];
// Enter info into the Database.
$query = "INSERT INTO orders (order_date,order_firstname,order_lastname,order_address1,
order_address2,order_city,order_state,order_zip,order_tel,order_email,item_total,
shipping_total,status,tax,total,session_id,cc_type,cc_number,cc_month,cc_year,cc_holder)
VALUES (localtime(),'$firstname','$lastname','$address1','$address2','$city','$state',
'$zip','$phone','$email','$subtotal','$shipping','','$tax','$total','$sesid','$cc_type',
'$cc_number','$cc_month','$cc_year','$cc_holder')";
$result = mysql_query($query);
echo mysql_error();
if(!$result){
echo 'Query error!';
} else {
// Get cart contents:
$get_cart = "select tr.id, inv.name, inv.price, tr.qty from tracker
as tr left join inventory as inv on inv.id = tr.item_id where session_id = '$userses'";
$get_cart_res = mysql_query($get_cart) or die(mysql_error());
$subject = "Your Order at blah.com!";
$message = "Dear $firstname $lastname,
Thank you for ordering at http://www.blah.com!
Order Summary:\n";
while ($cart = mysql_fetch_array($get_cart_res)) {
$name = stripslashes($cart['name']);
$price = $cart['price'];
$qty = $cart['qty'];
$message .= "$qty";
}
$message .= "Subtotal: $subtotal
Tax (Florida Residents Only): $tax
Shipping: $shipping
Total: $total
Thanks for the order...blahblahblah...";
mail($email, $subject, $message, "From: orders@blah.com\r\n");
header("Location: https://URL/logoff.php");
}
?>Code: Select all
"e;Dear John Doe,
Thank you for ordering at http://www.blah.com!
Order Summary:
Subtotal: 1000
Tax (Florida Residents Only): 70.00
Shipping: 10.00
Total: 1080.00
Thanks for the order...blahblahblah..."e;Code: Select all
Return-Path: <orders@blah.com>
Received: from blah.com (blah.com їxxx.xxx.xxx.xxx])
by routing.blah.com (8.11.6/8.11.6) with ESMTP id j2BFL5cxxxxx
for <johndoe@customer.com>; Fri, 11 Mar 2005 09:21:08 -0600
Received: (from blah@localhost)
by blah.com (8.11.6/8.11.6) id j2BFKvcxxxxx;
Fri, 11 Mar 2005 09:20:57 -0600
Date: Fri, 11 Mar 2005 09:20:57 -0600
Message-Id: <200503111520.j2BFKvcxxxxx@blah.com>
To: johndoe@customer.com
Subject: Your Order at blah.com!
From: orders@blah.com
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on
blah.com
X-Spam-Status: No, hits=0.3 required=99.0 tests=NO_REAL_NAME autolearn=no
version=2.63
X-Spam-Level:
Status:squatchimo wrote:OK, to test that thought, I modified the code to echo one of the results:
And the proper name is displayed. So the query does work and does return results. $cart is not empty.Code: Select all
$num = 160; $get_cart = "select tr.id, inv.name, inv.price, tr.qty from tracker as tr left join inventory as inv on inv.id = tr.item_id where tr.id = '$num'"; $get_cart_res = mysql_query($get_cart) or die(mysql_error()); while ($cart = mysql_fetch_array($get_cart_res)) { $name = stripslashes($cart['name']); $price = $cart['price']; $qty = $cart['qty']; $message .= "$qty. x .$name. - £.$price. each\n"; } echo $name;