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>Sale Menu</h2></center> <hr> <?php $counter = $_SESSION['counter']; //$items = array(); $quantities; if(!isset($counter)) { $counter = 0; } if(isset($_POST['Clear'])) { $counter = 0; unset($items); } if(isset($_POST['items'])) { $items[$counter] = $_POST['items']; $_SESSION['items'][$counter] = $items[$counter]; //echo "$items[$counter]<br>"; } //echo "counter is at $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'; // session converter for($m=1; $m<$counter+1; $m++) { $item = $_SESSION['items'][$m]; if(!isset($item)) { $flag[$m] = 0; } else { $flag[$m] = 1; } $query[$m] = "Select SKU, name, price from $table_name where SKU = '$item'"; $_SESSION['query'][$m] = $query[$m]; } ?> <form method=post> <?php if($connect) { MYSQL_select_db($database); print "<table border=3><center>"; print "<th>SKU<th>Name<th>Price<th>Quantity"; 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 = '$item.[$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) { //if(!isset($field)) //{ // echo "<td><input type=text name='quantity$i'></td>"; //} //else //{ print "<td>$field</td>"; //} } } if($flag[$i]==1) {echo "<td><input type=text size=10 placeholder=1 name='$i'></td>";} } //else //{echo "not working. <a href='uposdir.php'>Try again?</a>";} //test commands echo "</tr>"; } echo "</center></table><br>"; //for($j=1;$j<$counter+1; $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'><P>"; echo "<INPUT type='submit' name='Submit' value='Enter'>"; echo "<INPUT type='submit' name='Clear' value='Clear'>"; //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>"; ?> </form> <P> <form action="saleaction2.php" method=post> <input type=submit name="Checkout" value="Checkout"> <hr> <a href="uposdir.php"> <img src="HouseBlack.png" width="64" height="64"></a>