-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.php
181 lines (162 loc) · 7.93 KB
/
dashboard.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
<?php
include("connection.php");
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Query to retrieve the last inserted first name
$query = "SELECT `firstName` FROM `FORM` ORDER BY id DESC LIMIT 1";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$firstName = $row['firstName'];
} else {
// No results found
$firstName = "N/A";
}
// Use the $lastFirstName variable as needed
// echo "Last Inserted First Name: " . $lastFirstName;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<title>Home</title>
</head>
<body>
<div id="home">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<img class="logo" src="./images/backpacker.png" alt="">
<div class="navbar-brand-group">
<a class="navbar-brand" href="#">BagPackers</a>
<div class="name">Hi! <input type="text" name="firstName" value="<?php echo isset($firstName) ? $firstName : ''; ?>" readonly></div>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-expanded="false">
Top cities
</a>
<div class="dropdown-menu" id="topCitiesDropdown">
<a class="dropdown-item" href="#">Delhi</a>
<a class="dropdown-item" href="#">Mumbai</a>
<a class="dropdown-item" href="#">Kolkata</a>
<a class="dropdown-item" href="#">Chennai</a>
<a class="dropdown-item" href="#">Banglore</a>
<a class="dropdown-item" href="#">Hyderabad</a>
<a class="dropdown-item" href="#">Pune</a>
<a class="dropdown-item" href="#">Mysore</a>
<a class="dropdown-item" href="#">Jaipur</a>
</div>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Services <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About us</a>
</li>
<a href="./joinus.php">
<button class="btn my-2 my-sm-0" type="submit">Become a partner</button>
</a>
</ul>
</div>
</nav>
<!--main home body-->
<div class="middle-container">
<div class="card-wrapper-container">
<div class="title">
City
</div>
<div class="card mb-3">
<img src="./images/taj-mahal.jpeg" class="card-img-top" alt="...">
<div class="card-body">
<form action="#" method="POST">
<div class="row">
<div class="form-group col-6">
<label for="location">Region</label>
<input type="text" required class="form-control" name="region" id="location" placeholder="Enter Region">
</div>
<div class="form-group col-6">
<label for="bags">Number of Bags</label>
<input type="number" required class="form-control" id="bags" name="bags" placeholder="Enter number of bags">
</div>
</div>
<div class="row">
<div class="form-group col-6">
<label for="drop-off">Drop-off</label>
<input type="date" required class="form-control" id="drop-off" name="dropoff" placeholder="Enter drop-off option">
</div>
<div class="form-group col-6">
<label for="pickup">Pickup</label>
<input type="date" required class="form-control" id="pickup" name="pickup" placeholder="Enter pickup option">
</div>
</div>
<div class="row">
<!-- <button class="cta-btn" name="register">Register</button> -->
<button class="col-6" name="bill" class="cta-btn">Search</button>
<a href="./login.php" class="col-6">
Book now
</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Get the dropdown menu element
const dropdown = document.getElementById('topCitiesDropdown');
// Add click event listener to the dropdown menu items
dropdown.addEventListener('click', function(event) {
// Check if the clicked element is a dropdown item
if (event.target.classList.contains('dropdown-item')) {
// Get the selected city
const selectedCity = event.target.textContent;
// Get the title element and change its text
const titleElement = document.querySelector('.title');
titleElement.textContent = `${selectedCity}`;
// Get the image element and change its source
const imageElement = document.querySelector('.card-img-top');
imageElement.src = `./images/cities/${selectedCity.toLowerCase()}.jpeg`;
}
});
});
</script>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
</body>
</html>
<?php
include("connection.php");
if(isset($_POST['bill'])) {
$region = $_POST['region'];
$bags = $_POST['bags'];
$dropoff = $_POST['dropoff'];
$pickup = $_POST['pickup'];
// Insert data into the database if there are no errors
if(empty($errors)) {
$query = "INSERT INTO BILL (region, bags, dropoff, pickup) VALUES ('$region', '$bags', '$dropoff', '$pickup')";
$result = mysqli_query($conn, $query);
if ($result) {
// echo "Welcome to The Cure And Care.";
// session_start();
// $_SESSION['region'] = $region; // Assuming $region contains the region from the form
// header('location: map.php');
echo '<script>window.location.href = "map.php";</script>';
exit;
} else {
echo "An error occurred while registering.";
}
}
}
?>