-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsave.php
130 lines (51 loc) · 1.71 KB
/
save.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
65
<?php
include 'includes/db.php';
session_start();
if(!$_SESSION['username'])
{
header('location: login.php');
}
$username=$_SESSION['username'];
$sql= "SELECT * FROM users WHERE email = '$username'";
$sql_run = mysqli_query($con, $sql);
$row_a = mysqli_fetch_assoc($sql_run);
$user_id= $row_a['id'];
$user_id = $_POST['user_id'];
$invoice_number=$_POST['invoice_number'];
$client=$_POST['client'];
$project=$_POST['project'];
$workorder=$_POST['workorder'];
$discount=$_POST['discount'];
$gstrate=$_POST['gstrate'];
if (empty($_POST['date'])){
$date=date("Y-m-d");
} else {
$date=date("Y-m-d", strtotime($_POST['date']));
}
$dis='0';
$type=$_POST['type'];
$sqla="INSERT INTO data VALUES (NULL, '$user_id', '$invoice_number', '$type', '$client', '$project', '$workorder', '$gstrate', '$discount', '$date')";
$resulta = $con->query($sqla);
$sqlb="SELECT * FROM data WHERE invoice_number='$invoice_number'";
$result = mysqli_query($con, $sqlb);
$row=mysqli_fetch_assoc($result);
$data_id=$row['data_id'];
// $dbnm='vendex';
// $user='root';
// $pass='';
// try{
// $dbh = new PDO('mysql:host=localhost;dbname='.$dbnm, $user, $pass);
// } catch (PDOExeption $e) {
// print "Error".$e->getMessage()."<br>";
// die();
// }
$arr = $_POST;
for($i=1; $i <= count($arr['product']); $i++ ){
$product=$arr['product'][$i];
$qty=$arr['qty'][$i];
$desc=$arr['desc'][$i];
$rate=$arr['rate'][$i];
$sqli = mysqli_query($con, "INSERT INTO other_data VALUES (NULL, '$data_id', '$product', '$qty', '$desc', '$rate')");
}
header('location: invoice.php');
?>