Example #1
0
 function __construct()
 {
     $this->Conn = new mysqli('127.0.0.1', 'root', '', "tpsshop");
     if (mysqli_connect_errno()) {
         die("<p>Unable to connect to database.</p>" . "<p>Error code " . Mysqli_connect_errno() . ": " . mysqli_connect_errno()) . "</p>";
     }
 }
Example #2
0
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900" rel="stylesheet" />
<link href="default.php" rel="stylesheet" type="text/css" media="all" />
<link href="fonts.php" rel="stylesheet" type="text/css" media="all" />
<!--[if IE 6]>
<link href="default_ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->
</head>


<?php 
session_start();
$Conn = new mysqli('127.0.0.1', 'root', '', "tpsshop");
if (mysqli_connect_errno()) {
    die("<p>Unable to connect to database.</p>" . "<p>Error code " . Mysqli_connect_errno() . ": " . mysqli_connect_errno()) . "</p>";
}
$UpdQtySQL = "UPDATE orders SET status=1 WHERE id=" . $_SESSION['SESS_ORDERNUM'] . ";";
// update TOTAL in Oreder Table
@mysqli_query($Conn, $UpdQtySQL) or die(mysql_error());
$sql = "DELETE FROM orderitems WHERE order_id = " . $_SESSION['SESS_ORDERNUM'];
$del = mysqli_query($Conn, $sql) or die(mysql_error());
?>


<body>

	<?php 
require 'header.php';
?>
	
Example #3
0
         //'User has orders create orderitems for him';
         $itemsql = "INSERT INTO orderitems(order_id,product_id, quantity) VALUES(" . $_SESSION['SESS_ORDERNUM'] . ", " . $_GET['id'] . ", " . $_POST['amountBox'] . ")";
         @mysqli_query($Conn, $itemsql) or die(mysql_error());
         //echo "<p>ITEM ALREADY EXIST</p>";		// update the current quantity
         $totalprice = $prodrow['price'] * $_POST['amountBox'];
         // multiply quantity
         $UpdQtySQL = "UPDATE orders SET total = total + " . $totalprice . " WHERE id = " . $_SESSION['SESS_ORDERNUM'] . ";";
         // update TOTAL in Oreder Table
         @mysqli_query($Conn, $UpdQtySQL) or die(mysql_error());
     }
     header("Location: " . $config_basedir . "showcart.php");
 } else {
     if (isset($_SESSION['SESS_LOGGEDIN'])) {
         //'User dont have orders create an order for him';
         $OrderSQL = "INSERT INTO orders(customer_id,status, date) VALUES(" . $_SESSION['SESS_USERID'] . ", 0, NOW())";
         $QueryResult = @mysqli_query($Conn, $OrderSQL) or die("<p>Unable to create order.</p>" . "<p>Error code " . Mysqli_connect_errno() . ": " . mysqli_connect_errno()) . "</p>";
         // select the order id and then create oder itemsql
         // one process as i did for the login
         $PrderSQL = "SELECT id FROM orders WHERE customer_id = " . $_SESSION['SESS_USERID'] . " AND status = 0";
         // create an order if necessary
         $OrderQueryResult = @mysqli_query($Conn, $PrderSQL);
         $numrows = mysqli_num_rows($OrderQueryResult);
         if ($numrows != 0) {
             $orderrow = mysqli_fetch_assoc($OrderQueryResult);
             $_SESSION['SESS_ORDERNUM'] = $orderrow['id'];
             $itemsql = "INSERT INTO orderitems(order_id,product_id, quantity) VALUES(" . $_SESSION['SESS_ORDERNUM'] . ", " . $_GET['id'] . ", " . $_POST['amountBox'] . ")";
             @mysqli_query($Conn, $itemsql) or die(mysql_error());
             $totalprice = $prodrow['price'] * $_POST['amountBox'];
             // multiply quantity
             $UpdSQL = "UPDATE orders SET total = total + " . $totalprice . " WHERE id = " . $_SESSION['SESS_ORDERNUM'] . ";";
             @mysqli_query($Conn, $UpdSQL) or die(mysql_error());