-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentercar1.php
200 lines (169 loc) · 7.45 KB
/
entercar1.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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<html>
<head>
<title> customer Signup | Patna Car Rental </title>
</head>
<?php session_start(); ?>
<link rel="shortcut icon" type="image/png" href="P.png">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/fonts/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/customerlogin.css">
<link rel="stylesheet" href="assets/w3css/w3.css">
<script type="text/javascript" src="assets/js/jquery.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
<body>
<!-- Navigation -->
<nav class="navbar navbar-custom navbar-fixed-top" role="navigation" style="color: black">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
<i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="index.php">
PATNA CAR RENTAL </a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<?php
if(isset($_SESSION['login_client'])){
?>
<div class="collapse navbar-collapse navbar-right navbar-main-collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.php">Home</a>
</li>
<li>
<a href="#"><span class="glyphicon glyphicon-user"></span> Welcome <?php echo $_SESSION['login_client']; ?></a>
</li>
<li>
<ul class="nav navbar-nav navbar-right">
<li><a href="#" class="dropdown-toggle active" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user"></span> Control Panel <span class="caret"></span> </a>
<ul class="dropdown-menu">
<li> <a href="entercar.php">Add Car</a></li>
<li> <a href="enterdriver.php"> Add Driver</a></li>
<li> <a href="clientview.php">View</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="logout.php"><span class="glyphicon glyphicon-log-out"></span> Logout</a>
</li>
</ul>
</div>
<?php
}
else if (isset($_SESSION['login_customer'])){
?>
<div class="collapse navbar-collapse navbar-right navbar-main-collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.php">Home</a>
</li>
<li>
<a href="#"><span class="glyphicon glyphicon-user"></span> Welcome <?php echo $_SESSION['login_customer']; ?></a>
</li>
<li>
<a href="#">History</a>
</li>
<li>
<a href="logout.php"><span class="glyphicon glyphicon-log-out"></span> Logout</a>
</li>
</ul>
</div>
<?php
}
else {
?>
<div class="collapse navbar-collapse navbar-right navbar-main-collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.php">Home</a>
</li>
<li>
<a href="clientlogin.php">Client</a>
</li>
<li>
<a href="customerlogin.php">Customer</a>
</li>
<li>
<a href="#"> FAQ </a>
</li>
</ul>
</div>
<?php }
?>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<?php
require 'connection.php';
$conn = Connect();
function GetImageExtension($imagetype) {
if(empty($imagetype)) return false;
switch($imagetype) {
case 'assets/img/cars/bmp': return '.bmp';
case 'assets/img/cars/gif': return '.gif';
case 'assets/img/cars/jpeg': return '.jpg';
case 'assets/img/cars/png': return '.png';
default: return false;
}
}
$car_name = $conn->real_escape_string($_POST['car_name']);
$car_nameplate = $conn->real_escape_string($_POST['car_nameplate']);
$ac_price = $conn->real_escape_string($_POST['ac_price']);
$non_ac_price = $conn->real_escape_string($_POST['non_ac_price']);
$ac_price_per_day = $conn->real_escape_string($_POST['ac_price_per_day']);
$non_ac_price_per_day = $conn->real_escape_string($_POST['non_ac_price_per_day']);
$car_availability = "yes";
//$query = "INSERT into cars(car_name,car_nameplate,ac_price,non_ac_price,car_availability) VALUES('" . $car_name . "','" . $car_nameplate . "','" . $ac_price . "','" . $non_ac_price . "','" . $car_availability ."')";
//$success = $conn->query($query);
if (!empty($_FILES["uploadedimage"]["name"])) {
$file_name=$_FILES["uploadedimage"]["name"];
$temp_name=$_FILES["uploadedimage"]["tmp_name"];
$imgtype=$_FILES["uploadedimage"]["type"];
$ext= GetImageExtension($imgtype);
$imagename=$_FILES["uploadedimage"]["name"];
$target_path = "assets/img/cars/".$imagename;
if(move_uploaded_file($temp_name, $target_path)) {
//$query0="INSERT into cars (car_img) VALUES ('".$target_path."')";
// $query0 = "UPDATE cars SET car_img = '$target_path' WHERE ";
//$success0 = $conn->query($query0);
$query = "INSERT into cars(car_name,car_nameplate,car_img,ac_price,non_ac_price,ac_price_per_day,non_ac_price_per_day,car_availability) VALUES('" . $car_name . "','" . $car_nameplate . "','".$target_path."','" . $ac_price . "','" . $non_ac_price . "','" . $ac_price_per_day . "','" . $non_ac_price_per_day . "','" . $car_availability ."')";
$success = $conn->query($query);
}
}
// Taking car_id from cars
$query1 = "SELECT car_id from cars where car_nameplate = '$car_nameplate'";
$result = mysqli_query($conn, $query1);
$rs = mysqli_fetch_array($result, MYSQLI_BOTH);
$car_id = $rs['car_id'];
$query2 = "INSERT into clientcars(car_id,client_username) values('" . $car_id ."','" . $_SESSION['login_client'] . "')";
$success2 = $conn->query($query2);
if (!$success){ ?>
<div class="container">
<div class="jumbotron" style="text-align: center;">
Car with the same vehicle number already exists!
<?php echo $conn->error; ?>
<br><br>
<a href="entercar.php" class="btn btn-default"> Go Back </a>
</div>
<?php
}
else {
header("location: entercar.php"); //Redirecting
}
$conn->close();
?>
</body>
<footer class="site-footer">
<div class="container">
<hr>
<div class="row">
<div class="col-sm-6">
<h5>© 2018 Patna Car Rental</h5>
</div>
</div>
</div>
</footer>
</html>