-
Notifications
You must be signed in to change notification settings - Fork 0
/
history.php
105 lines (82 loc) · 2.56 KB
/
history.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
// Check your database config:
$username="root";
$password="mysql";
$database="Art Supply Store";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Database Error");
function sanitise($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
class Purchase
{
public $credit;
public $item;
public $stock;
public $date_purchased;
}
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$post_purchase = new Purchase ();
$credit = sanitise ($_POST ["purchase_credit"]);
$post_purchase->item = sanitise ($_POST["purchase_item "]);
$post_purchase->quantity = sanitise ($_POST["purchase_quantity"]);
$post_purchase->date_purchased = sanitise ($_POST["purchase_date"]);
$valid = true;
$Errorcode = "";
if (empty($post_purchase->credit))
{
$valid = false;
$Errorcode = "card number empty";
}
$rows = mysql_query ("SELECT * purchase WHERE credit = $credit;");
for ($i = 0; $i < mysql_num_rows($rows); $i++)
{
$credit = mysql_result ($rows, $i , "purchase_credit");
$item = mysql_result ($rows, $i , "purchase_item");
$quantity = mysql_result ($rows, $i , "purchase_quantity");
$date_purchased = mysql_result ($rows, $i , "purchase_date");
echo "<tr>";
echo "<td>$credit</td>";
echo "<td>$item</td>";
echo "<td>$quantity</td>";
echo "<td>$date_purchased</td>";
echo "</tr>";
}
}
?>
<html>
<header><h1>Art Supply Store</h1>
<link rel="stylesheet" href="artsupply.css">
<nav>
<a href="home.php">Home</a>
<a href="Artsupplystore.php">Products</a>
<a href="packagepage.php">Packages</a>
<a href="purchasepage.php">Purchase</a>
</nav></header>
<body>
<h2>History details</h2>
</br>
<table>
<tr>
<th>Credit number</th>
<th>Item</th>
<th>Stock</th>
<th>Date</th>
<th></th>
</tr>
</table>
<form action="history.php" method="POST" >
<label>Credit card number</label>
<input name="purchase_credit" >
<input type="submit" name="submit" value="View">
</form>
</body>
</html>
<?php
mysql_close();
?>