-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessGiveProduct.php
64 lines (52 loc) · 1.71 KB
/
processGiveProduct.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
<?php
session_start();
require_once "configuration.php";
//require_once "header.php";
require_once $ROOT_PATH."administrator/utility/crud.php";
require_once $ROOT_PATH."administrator/utility/idEncode.php";
$productid = $_POST['product'];
$quantity = $_POST['txtQuantity'];
$uid = $_SESSION['userid'];
$unit = $_POST['unit'];
$description = $_POST['txtDESC'];
$date = date('Y-m-d');
if($_GET['action']=='delete')
{
deleteRecord('userproduct',$_GET['id']);
header("location: giveProduct.php");
}
else if(!$productid || !$quantity)
{
$_SESSION['message'] = "Please fill up all the fields";
header("location:giveProduct.php");
}
else if($quantity<0)
{
$_SESSION['message'] = "Negative values are not accepted";
header("location:giveProduct.php");
}
else
{
require_once("connect.php");
$sql = "SELECT userDetailsID FROM userdetails WHERE userID = '".$_SESSION['userid']."';";
//echo $sql;
$res = mysqli_query($con,$sql);
$rec = mysqli_fetch_array($res);
$ucID = $rec['userDetailsID'];
$_SESSION['userDeatailsID'] = $ucID;
$sql = "INSERT INTO userproduct(userDetailsID,productID,quantity,unitID,userProductDescription,postedDate) VALUES($ucID,$productid,$quantity,$unit,'$description','$date');";
if(!mysqli_query($con,$sql))
{
mysqli_close($con);
var_dump($sql);
$_SESSION['message'] = $_SESSION['userDeatailsID'];
//aheader("location:giveProduct.php");
}
else
{
mysqli_close($con);
$_SESSION['message'] = "Product added Successfully";
header("location:giveProduct.php");
}
}
?>