forked from aemunahmar/DBProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewVehicle.php
More file actions
44 lines (38 loc) · 1.56 KB
/
newVehicle.php
File metadata and controls
44 lines (38 loc) · 1.56 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
<?php
session_start();
include('dbconnect.php');
$serial = filter_input(INPUT_POST, 'serial');
$model = filter_input(INPUT_POST, 'model');
$color = filter_input(INPUT_POST, 'color');
$autotrans = filter_input(INPUT_POST, 'autotrans');
$warehouse = filter_input(INPUT_POST, 'warehouse');
$global = mysqli_connect("127.0.0.1", "root", "", "globalviews");
$sql = "SELECT model FROM rebate_Global WHERE model = '$model'";
$output = $global->query($sql);
if($output->num_rows != 0)
{
$answer = 'Yes';
} else
{
$answer = 'No';
}
if(isset($_SESSION['ldmanager1']))
{
$connection = mysqli_connect("127.0.0.1", "root", "", "dealer_one");
$sql = "INSERT INTO cars (serial_no, model, color, autotrans, warehouse, rebate)
VALUES ('$serial', '$model', '$color', '$autotrans', '$warehouse', '$answer')";
} else if(isset($_SESSION['ldmanager2']))
{
$connection = mysqli_connect("127.0.0.1", "root", "", "dealer_two");
$sql = "INSERT INTO autos (vehicle_no, model, color, autotrans, warehouse, rebate)
VALUES ('$serial', '$model', '$color', '$autotrans', '$warehouse', '$answer')";
}
if ($connection->query($sql) === TRUE)
{
echo "<script>alert('New Vehicle Added'); window.location.href='empAccount.html';</script>";
} else
{
//echo "Something went wrong" . "<br>" . $connection->error;
echo "<script>alert('Vehicle already exists'); window.location.href='addVehicle.html';</script>";
}
?>