-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_func.php
More file actions
130 lines (81 loc) · 3.32 KB
/
admin_func.php
File metadata and controls
130 lines (81 loc) · 3.32 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
require_once 'connect.php';
// function cost_calc()
// {
// $connection = mysqli_connect('localhost', 'root', '', 'parking');
// if (isset($_POST['search'])) {
// $veh_no = $_POST['v_name'];
// $query = "SELECT DATEDIFF(CURRENT_DATE,(SELECT Parking_date from book_details where vehicle_no = '$veh_no') ) as cost";
// $date_query = "SELECT Parking_date from book_details where vehicle_no = '$veh_no'";
// $result = mysqli_query($connection, $query);
// $date_result = mysqli_query($connection, $date_query);
// if (!$result) {
// die('sql query failed');
// }
// $cost = mysqli_fetch_array($result);
// $parking_date = mysqli_fetch_array($date_result);
// if (is_null($parking_date))
// echo '<script>alert("No vehicles found")</script>';
// else {
// $_SESSION['park_cost'] = ($cost[0] + 1) * 30;
// $_SESSION['date_park'] = $parking_date[0];
// }
// }
// }
// function remove_car()
// {
// require_once 'connect.php';
// $connection = mysqli_connect('localhost', 'root', '', 'parking');
// cost_calc();
// if (isset($_POST['details'])) {
// $veh_no = $_POST['v_num'];
// $query = "SELECT DATEDIFF(CURRENT_DATE,(SELECT Parking_date from book_details where vehicle_no = '$veh_no') ) as cost";
// $date_query = "SELECT Parking_date from book_details where vehicle_no = '$veh_no'";
// $result = mysqli_query($connection, $query);
// $date_result = mysqli_query($connection, $date_query);
// if (!$result) {
// die('sql query failed');
// }
// $cost = mysqli_fetch_array($result);
// $parking_date = mysqli_fetch_array($date_result);
// if (is_null($parking_date))
// echo '<script>alert("No vehicles found")</script>';
// else {
// $_SESSION['park_cost'] = ($cost[0] + 1) * 30;
// $_session['date_park'] = $parking_date[0];
// }
// }
// if (isset($_POST['remove'])) {
// $vechicle = $_POST['v_num'];
// $query = "DELETE FROM book_details where vehicle_no='$vechicle'";
// mysqli_query($connection, $query);
// echo '<script>alert("Vehicle removed and Money collected")</script>';
// }
// }
function add_car()
{
require_once 'connect.php';
$connection = mysqli_connect('localhost', 'root', '', 'parking');
if(isset($_POST['add'])) {
$uname = $_POST['u_name'];
$phone_no = $_POST['phno'];
$v_no = $_POST['v_num'];
$count_query = "SELECT COUNT(*) FROM book_details";
$result = mysqli_query($connection, $count_query);
$count = mysqli_fetch_array($result);
if($count[0] < 50)
{
$query = "INSERT INTO book_details(u_name, phone_no, vehicle_no, Parking_date) VALUES ('$uname', '$phone_no' , '$v_no' ,CURRENT_DATE)";
$result = mysqli_query($connection, $query);
if (!isset($result))
die('query failed' . mysqli_error($result));
else {
echo '<script>alert("Vechicle inserted")</script>';
}
}
else
{
echo '<script>alert("Lot full")</script>';
}
}
}