topical media & game development
basic-php-15-checkout3.php / php
<?php
session_start();
//connect to the database - either include a connection variable file
//or type the following lines:
firstname = lastname = firstname = add1 = add2 = city = state = zip = phone = fax = email = shipfirst = shiplast = shipadd1 = shipadd2 = shipcity = shipstate = shipzip = shipstate = shipphone = shipemail = total = sessid = session_id();
query = "SELECT * FROM customers WHERE
(customers_firstname = 'lastname' AND
customers_add1 = 'add2' AND
customers_city = 'results = mysql_query(rows = mysql_num_rows(rows < 1) {
//assign new custnum
firstname',
'add1',
'city',
'zip',
'fax',
'insert = mysql_query(custid = mysql_insert_id();
}
//If custid exists, we want to make it equal to custnum
//Otherwise we will use the existing custnum
if (customers_custnum = shipping = query3 = "INSERT INTO ordermain (
ordermain_orderdate, ordermain_custnum,
ordermain_subtotal,ordermain_shipping,
ordermain_shipfirst, ordermain_shiplast,
ordermain_shipadd1, ordermain_shipadd2,
ordermain_shipcity, ordermain_shipstate,
ordermain_shipzip, ordermain_shipphone,
ordermain_shipemail)
VALUES (
'customers_custnum',
'shipping'
'shiplast',
'shipadd2',
'shipstate',
'shipphone',
'insert2 = mysql_query(orderid = mysql_insert_id();
//3) Insert Info into orderdet
//find the correct cart information being temporarily stored
sessid'";
query)
or (mysql_error());
//put the data into the database one row at a time
while (results)) {
extract(query4 = "INSERT INTO orderdet (
orderdet_ordernum, orderdet_qty, orderdet_prodnum)
VALUES (
'carttemp_quan',
'insert4 = mysql_query(query = "DELETE FROM carttemp WHERE carttemp_sess='delete = mysql_query(to = "<" . subject = "Order Confirmation";
/* message */
/* top of message */
message .= message .= "
<br>
Order Number: ";
orderid;
message .= message .= " ";
lastname;
message .= message .= "<br>";
if (message .= message .= state . " " . message .= "</p></td>
<td>
<p>Ship to:<br>";
shipfirst . " " . message .= "<br>";
shipadd1 . "<br>";
if (message .= message .= shipstate . " " . message .= "</p>
</td>
</tr>
</table>
<hr width=\"250px\" align=\"left\">
<table cellpadding=\"5\">";
//grab the contents of the order and insert them
//into the message field
orderid'";
query)
or die (mysql_query());
while (results)) {
extract(prod = "SELECT * FROM products
WHERE products_prodnum = 'prod2 = mysql_query(prod3 = mysql_fetch_array(prod3);
message .= message .= "</td>";
message .= message .= "</td>";
message .= message .= "</td>";
extprice = number_format(orderdet_qty, 2);
extprice;
message .= "</tr>";
}
message .= number_format(message .= "
</td>
</tr>
<tr>
<td colspan=\"3\" align=\"right\">
Shipping Costs:
</td>
<td align=\"right\">";
shipping, 2);
message .= number_format((shipping), 2);
headers = "MIME-Version: 1.0\r\n";
headers .= "From: <storeemail@email.com>\r\n";
headers .= "X-Mailer: PHP / ".phpversion()."\r\n";
/* mail it */
mail(subject, headers);
//6)show them their order & give them an order number
echo "Step 1 - Please Enter Billing and Shipping Information<br>";
echo "Step 2 - Please Verify Accuracy and Make Any Necessary Changes<br>";
echo "<strong>Step 3 - Order Confirmation and Receipt</strong><br><br>";
echo
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.