Initial commit
This commit is contained in:
33
indexes/process/modify/item_add.php
Normal file
33
indexes/process/modify/item_add.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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"])) {
|
||||
$name = $_GET["name"];
|
||||
//seller cannot add more than 100kg
|
||||
if($usertype == "seller"){
|
||||
$sql_check = "SELECT $name FROM seller WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $sql_check);
|
||||
$num = mysqli_fetch_array($res);
|
||||
if($num[$name] + 1 > 100){
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You cannot sell more than 100kg/fruit one time!');
|
||||
window.location.href = '../cart_index.php';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
$add = "UPDATE $usertype SET $name = $name + 1 WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
if(!$res){
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: ../cart_index.php');
|
||||
?>
|
||||
Reference in New Issue
Block a user