window.top.location.href = '../../home.php'; "; return; } $check_sql = "SELECT $a FROM inventory WHERE name = '$name'"; $res = mysqli_query($conn, $check_sql); $avail = mysqli_fetch_array($res); //if not available if($avail[$a] != 1){ echo ""; return; } $sql_quant = "SELECT $name FROM $usertype WHERE name='$username'"; $res = mysqli_query($conn, $sql_quant); if ($res) { $num = mysqli_fetch_array($res); //if seller tries to sell more than 100kg fruits if(($usertype == "seller" && $num[$name] + $quantity <= 100) || $usertype == "buyer"){ $add = "UPDATE $usertype SET $name = $name+$quantity WHERE name='$username'"; $res = mysqli_query($conn, $add); } else{ echo ""; return; } } } header('Location: ./interfaces/success.php'); ?>