-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminPlace.php
215 lines (191 loc) · 5.84 KB
/
adminPlace.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
session_start();
include ("database/connection.php");
include ("_admin.php");
$conn = new mysqli('localhost', 'root', '', 'travel');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$tour_id = $conn->real_escape_string($_POST["tour_id"]);
$tour_Division = $conn->real_escape_string($_POST["tour_Division"]);
$tour_name = $conn->real_escape_string($_POST["tour_name"]);
$Place_type = $conn->real_escape_string($_POST["Place_type"]);
$tour_price = $conn->real_escape_string($_POST["tour_price"]);
$tour_image = $conn->real_escape_string($_POST["tour_image"]);
$tour_register = $conn->real_escape_string($_POST["tour_register"]);
if (isset($_POST["submit1"])) {
$stmt = $conn->prepare("INSERT INTO place (tour_id, tour_Division, tour_name, Place_type, tour_price, tour_image, tour_register) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssssiss", $tour_id, $tour_Division, $tour_name, $Place_type, $tour_price, $tour_image, $tour_register);
$stmt->execute();
$stmt->close();
echo "Successfully inserted";
}
if (isset($_POST["submit2"])) {
$stmt = $conn->prepare("DELETE FROM place WHERE tour_id = ?");
$stmt->bind_param("s", $tour_id);
$stmt->execute();
$stmt->close();
echo "Successfully deleted";
}
if (isset($_POST["submit3"])) {
$stmt = $conn->prepare("UPDATE place SET tour_Division = ?, tour_name = ?, Place_type = ?, tour_price = ?, tour_image = ?, tour_register = ? WHERE tour_id = ?");
$stmt->bind_param("sssisds", $tour_Division, $tour_name, $Place_type, $tour_price, $tour_image, $tour_register, $tour_id);
$stmt->execute();
$stmt->close();
echo "Successfully updated";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
color: #333;
margin: 0;
padding: 0;
}
.container {
display: flex;
justify-content: space-between;
align-items: flex-start;
padding: 20px;
}
#box1 {
background-color: #333;
color: #fff;
padding: 20px;
width: 300px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
form div {
margin-bottom: 15px;
}
input[type="text"],
input[type="number"],
input[type="date"] {
width: 100%;
padding: 8px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
input[type="submit"] {
background-color: #5cb85c;
color: white;
padding: 10px;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #4cae4c;
}
table {
width: 100%;
border-collapse: collapse;
margin: 0 20px;
}
table,
th,
td {
border: 1px solid #ddd;
}
th,
td {
padding: 12px;
text-align: left;
}
th {
background-color: #333;
color: white;
}
</style>
</head>
<body>
<div class="container">
<div id="box1">
<form method="post">
<div style="font-size: 20px; margin: 10px; color: white;">Place Info</div>
<div>
<label for="tour_id">Place ID</label>
<input id="text" type="text" name="tour_id" required>
</div>
<div>
<label for="tour_Division">Divisions</label>
<input id="text" type="text" name="tour_Division">
</div>
<div>
<label for="tour_name">Place Name</label>
<input id="text" type="text" name="tour_name">
</div>
<div>
<label for="Place_type">Place Type</label>
<input id="text" type="text" name="Place_type">
</div>
<div>
<label for="tour_price">Price</label>
<input id="text" type="number" name="tour_price">
</div>
<div>
<label for="tour_image">Image</label>
<input id="text" type="text" name="tour_image">
</div>
<div>
<label for="tour_register">Event Date</label>
<input id="text" type="date" name="tour_register">
</div>
<div class="btn">
<input type="submit" value="Insert" name="submit1">
</div>
<div class="btn">
<input type="submit" value="Delete" name="submit2">
</div>
<div class="btn">
<input type="submit" value="Update" name="submit3">
</div>
</form>
</div>
<div>
<table>
<tr>
<th>Place_id</th>
<th>Divisions</th>
<th>Place_name</th>
<th>Place_type</th>
<th>Price</th>
<th>Image</th>
<th>Event Date</th>
</tr>
<?php
$sql = "SELECT `tour_id`, `tour_Division`, `tour_name`, `Place_type`, `tour_price`, `tour_image`, `tour_register` FROM `place`";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>
<td>{$row['tour_id']}</td>
<td>{$row['tour_Division']}</td>
<td>{$row['tour_name']}</td>
<td>{$row['Place_type']}</td>
<td>{$row['tour_price']}</td>
<td><img src='" . $row["tour_image"] . "' alt='Image' width='50'></td>
<td>{$row['tour_register']}</td>
</tr>";
}
} else {
echo "<tr><td colspan='7'>No results found</td></tr>";
}
$conn->close();
?>
</table>
</div>
</div>
</body>
</html>