Initial commit
This commit is contained in:
34
indexes/process/modify/item_checkup_modify.php
Normal file
34
indexes/process/modify/item_checkup_modify.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include "../../ConnectDB.php";
|
||||
session_start();
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
|
||||
if (isset($_GET["name"], $_GET["quantity"])) {
|
||||
if ($_GET["quantity"] > 0 && ($_GET["quantity"] <= 100 || $usertype == "buyer")) {
|
||||
$quantity = $_GET["quantity"];
|
||||
$name = mysqli_real_escape_string($conn, $_GET["name"]);
|
||||
$add = "UPDATE $usertype SET `$name` = $quantity WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
else if ($_GET["quantity"] > 100 && $usertype == "seller") {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You can only buy 100kg of each type of fruit at a time!');
|
||||
</script>";
|
||||
}
|
||||
else{
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You cannot buy nothing!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = '../checkup.php';
|
||||
</script>";
|
||||
?>
|
||||
Reference in New Issue
Block a user