-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.php
More file actions
60 lines (41 loc) · 1.3 KB
/
add.php
File metadata and controls
60 lines (41 loc) · 1.3 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
<?php
session_start();
date_default_timezone_set('Asia/Kolkata');
$updated_time= date('d-M-y h:i a', time());
$name = $_SESSION['name'];
$user = implode($name);
$item=$_SESSION["Item"];
$quantity=$_SESSION["Quantity"];
$price=$_SESSION["Price"];
if(!empty($_POST))
{
if(isset($_POST['entry']))
{
include("./database/db_connection.php");
/*if($con->connect_error)
{
die('Connect Error:'.$con->connect_errorno.':'.$con->connect_error);
}*/
$date=mysqli_real_escape_string($con,$_SESSION["date"]);
$m=DateTime::createFromFormat('!d-M-y', $date);
$month=strtoupper($m->format('M'));
$year=strtoupper($m->format('Y'));
// $item=mysqli_real_escape_string($con,$_SESSION["Item"]);
// $quantity=mysqli_real_escape_string($con,$_SESSION["Quantity"]);
// $price=mysqli_real_escape_string($con,$_SESSION["Price"]);
$products=mysqli_real_escape_string($con,$_SESSION["products"]);
for($i=0; $i<$products; $i++)
{
$sql=mysqli_query($con,"INSERT INTO `daily_purchase` (`Date`, `Item`, `Quantity`, `Price`, `Buyer`, `Month`, `Year`) VALUES ('$date', '$item[$i]', '$quantity[$i]', '$price[$i]', '$user', '$month', '$year')");
}
if($sql===TRUE)
{
header("location:success.php");
}
else
{
echo "Error".$sql."<br>".$con->error;
}
}
}
?>