-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinventory_config_post.php
50 lines (38 loc) · 1.36 KB
/
inventory_config_post.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
<?php
require_once ('conn.php');
if(isset($_POST["type"])){
$result = mysqli_query($con,"SELECT * FROM inventory_config_types WHERE genre = '$_POST[genre]' ORDER BY table_index DESC LIMIT 1");
$row = mysqli_fetch_array($result);
$serial = null;
if(mysqli_num_rows($result)!=0){
$last = $row['serial_no'];
$serial = $last + 1;
} else{ $serial = 1;}
$sql="INSERT INTO inventory_config_types (type,genre,serial_no) VALUES ('$_POST[type]','$_POST[genre]','$serial')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
echo "1 record added";
mysqli_close($con);
}
header('Location: inventory_configuration.php?msg=success');
}
else if(isset($_POST["color"])){
$result = mysqli_query($con,"SELECT * FROM inventory_config_colors ORDER BY table_index DESC LIMIT 1");
$row = mysqli_fetch_array($result);
$serial_no = null;
if(mysqli_num_rows($result)!=0){
$last = $row['serial_no'];
$serial_no = $last + 1;
} else{ $serial_no = 1;}
$sql="INSERT INTO inventory_config_colors (color,serial_no) VALUES ('$_POST[color]','$serial_no')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
echo "1 record added";
mysqli_close($con);
}
header('Location: inventory_configuration.php?msg=success');
}else {
header('Location: inventory_configuration.php?msg=fail');
}