Server IP : 172.16.15.8 / Your IP : 18.189.186.247 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/wcdavis/www/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php session_start(); ?> <head> <link rel="stylesheet" type="text/css" href="upos.css"> </head> <H2><center>Checkout Page</H2></center> <HR> Your Order: <?php $counter = $_SESSION['counter']; if(isset($counter)) { $counter--; // offset count up from previous page $host = 'localhost'; $user = 'wcdavis'; $pass = 'cs480'; $database = 'wcdavis'; $saleuser = $_POST['username']; $_SESSION['saleuser'] = $saleuser; //storenum should still be intact $connect = mysql_connect($host, $user, $pass); $table_name = 'ITEMS'; $total = 0; // evaluate function mysql_evaluate($query, $default_value="undefined") { $result = mysql_query($query); if (mysql_num_rows($result)==0) {return $default_value;} else {return mysql_result($result,0);} } if($connect) { MYSQL_select_db($database); //the session converter to generate item info for($m=1; $m<$counter+1; $m++) { $item = $_SESSION['items'][$m]; $query[$m] = "Select SKU, name, price from $table_name where SKU = '$item'"; $_SESSION['query'][$m] = $query[$m]; //$_SESSION['quantity'][$m] = $_POST['$m']; $quantity[$m] = 1; //echo "$quantity[$m]<br>"; $value = mysql_evaluate("SELECT price FROM ITEMS WHERE sku = '$item'", "DEFAULT_TYPE"); //echo "$value<br>"; $subtotal[$m] = $value * 1.06; // adjusting for tax $subtotal[$m] = number_format($subtotal[$m], 2); $total = $total + $subtotal[$m]; } $tax = 0.06 * $total; $tax = number_format($tax, 2); print "<table border=3><center>"; print "<th>SKU<th>Name<th>Price<th>Quantity<th>Subtotal"; for($i=1;$i<$counter+1;$i++) // this is going to create each query to check SQL { //$query[$i] = "Select SKU, name, price from $table_name where SKU = '${items . $i}'"; //echo "$query[$i] <br>"; $result_id[$i] = mysql_query($query[$i], $connect); if($result_id) { while($row=mysql_fetch_row($result_id[$i])) { print "<tr>"; foreach ($row as $field) { print "<td>$field</td>"; } } echo "<td>$quantity[$i]</td>"; echo "<td>$subtotal[$i]</td>"; //echo ""; echo "</tr>"; } } //else //{echo "not working. <a href='uposdir.php'>Try again?</a>";} //test commands } echo "</center></table><br>"; // for($j=1;$j<=$counter; $j++) // {echo "$query[$j] <BR>";} echo "<br>Tax:  <b>$tax</b><br>"; echo "Your Total is:   <b>$total</b></b>"; ?> <form action="" method=post> <br> <b>Payment Options:</b> <?php echo "(please enter a total of $total)<br>"; echo "Cash: <input type=text name=cash placeholder=0 size=10><br>"; echo "Check: <input type=text name=check placeholder=0 size=10><br>"; echo "Credit Card: <input type=text name=credit placeholder=0 size=10><br>"; echo "<input type=submit name=submit>"; echo "<INPUT type='submit' name='Clear' value='Reset'></form>"; $sum = $_SESSION['sum']; if(!isset($_SESSION['sum'])) { $sum = 0; // presumably the first time } //receive values from submission after pressing submit if($sum < $total) { $cash = (int)$_POST['cash']; $check = (int)$_POST['check']; $credit = (int)$_POST['credit']; $giftcard = (int)$_POST['giftcard']; if(isset($_POST['Reset'])) { $cash = 0; $check = 0; $credit = 0; $giftcard = 0; unset($sum); } $sum = $cash + $check + $credit + $giftcard; $sum = number_format($sum, 2); $_SESSION['sum'] = $sum; echo "Total payment so far = $sum"; $diff = $total - $sum; //echo "<p>Still need $diff in payment<br>"; } else { $_SESSION['sum'] = $sum; $_SESSION['cash'] = $cash; $_SESSION['check'] = $check; $_SESSION['credit'] = $credit; $_SESSION['total'] = $total; $_SESSION['giftcard'] = $giftcard; echo "<form action=saleaction3.php method=post>"; echo "<p><INPUT type='submit' name='Submit' value='Checkout'>"; echo "</form>"; } ?> <HR> <a href="saleactiontest.php">Not exactly right?</A><p> <?php } else { echo "Nothing selected. <a href='saleactiontest.php'>Please select something to sell</a><p>"; } mysql_close($connect); ?> <a href="uposdir.php"> <img src="HouseBlack.png" width="64" height="64"></a>