-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem.php
More file actions
76 lines (71 loc) · 1.91 KB
/
item.php
File metadata and controls
76 lines (71 loc) · 1.91 KB
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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
session_start();
?>
<?php
//$protitle=$_POST['protitle'];
//$mdnum=$_POST['mdnum'];
$name=$_POST['name'];
$quan=$_POST['quan'];
$_SESSION["quantity"]=$quan;
$issuedate=$_POST['issuedate'];
$returndate=$_POST['returndate'];
$_SESSION["issuedate"]=$issuedate;
$_SESSION["returndate"]=$returndate;
/*
$username=stripcslashes($username);
$password=stripcslashes($password);
$username=mysql_real_escape_string($username);
$password=mysql_real_escape_string($password);
*/
$db_username = 'root';
$db_password = '';
$db_name = 'users';
$db_host = 'localhost';
$quantity="";
//connect to MySql
$mysqli = new mysqli($db_host, $db_username, $db_password,$db_name);
if ($mysqli->connect_error) {
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
$sql = "select * from product where name='$name'";
$_SESSION["name"]=$name;
$result = $mysqli->query($sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
// echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
$quantity=$row["quantity"];
$sum=$sum+$quantity;
$_SESSION["productid"]=$row["id"];
// $_SESSION["name"]=$name;
}
} else {
echo "0 results";
}
echo $sum;
if($quan>$sum)
{
echo "product is short the request has been send to admin for this product";
$_SESSION["msg"]="product".$name." is short";
}
else
{
$username1=$_SESSION["username"];
//echo $username1;
echo "your request for product has been send to admin ";
$_SESSION["msg"]="person ".$username1."want ".$name."";
// echo $_SESSION["msg"];
}
$mysqli->close();
?>
<form method="post" action="index.html">
<input type="submit" name="Logout" value="logout">
</form>
</body>
</html>