-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddLocations.php
More file actions
144 lines (130 loc) · 5.01 KB
/
addLocations.php
File metadata and controls
144 lines (130 loc) · 5.01 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!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">
<title>Add Location</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
font: 14px sans-serif;
}
table {
table-layout: fixed;
max-width: 100%;
border-collapse: collapse;
margin: .25rem auto .5rem auto;
}
td {
padding: 1rem;
}
tr td:nth-child(1) {
font-weight: bold;
}
</style>
<style>
.btn-custom {
display: inline-block;
padding: 8px 14px;
font-size: 14px;
font-weight: bold;
color: #f8f9fa;
/* Warna teks lebih lembut */
background: linear-gradient(135deg, #2C3E50, #4A6274);
/* Navy ke abu-abu */
border: none;
border-radius: 8px;
text-decoration: none;
transition: all 0.3s ease-in-out;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}
.btn-custom:hover {
background: linear-gradient(135deg, #4A6274, #2C3E50);
transform: translateY(-2px);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}
.btn-custom:active {
transform: scale(0.95);
}
</style>
</head>
<body>
<div id="button-container" class=" d-flex ml-2 mt-2">
<a href="#" id="home-button" class="btn-custom" onclick="history.back(); return false;">🔙 Home</a>
</div>
<br>
<h2 class="text-center mb-4">Add location</h2>
<form action="addLocations.php" method="post" name="form1">
<table>
<tr>
<td>location ID: </td>
<td><input type="number" name="locations_id" required min="1" class="form-control"></td>
</tr>
<tr>
<td>location Name: </td>
<td><input type="text" name="locations_name" required class="form-control"></td>
</tr>
<tr>
<td>location Status: </td>
<label for="locations_status"></label>
<td><select name="locations_status" required class="form-control">
<option value="">Select Location Status</option>
<option value="The Demon World">The Demon World</option>
<option value="The Human World">The Human World</option>
<option value="Other">Other</option>
</select>
</tr>
<tr>
<td>location Type: </td>
<label for="locations_type"></label>
<td><select name="locations_type" required class="form-control">
<option value="">Select Location Type</option>
<option value="Plantation">Plantation</option>
<option value="Stonehenge">Stonehenge</option>
<option value="Hideout">Hideout</option>
<option value="Other">Other</option>
<option value="-">-</option>
</select>
</tr>
<tr>
<td>Location Observer ID: </td>
<td><input type="number" name="observer_id" required min="1" class="form-control"></td>
</tr>
<tr>
<td>Location Children ID: </td>
<td><input type="number" name="child_id" required min="1" class="form-control"></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="submit" class="btn btn-primary">
</td>
</tr>
</table>
</form>
<?php
// Check If form submitted, insert form data into users table.
if (isset($_POST['submit'])) {
$locations_id = $_POST['locations_id'];
$locations_name = $_POST['locations_name'];
$locations_status = $_POST['locations_status'];
$locations_type = $_POST['locations_type'];
$observer_id = $_POST['observer_id'];
$child_id = $_POST['child_id'];
// include database connection file
include_once("config.php");
// Insert user data into table
$query = "INSERT INTO locations (locations_id, locations_name, locations_status, locations_type, observer_id, child_id) VALUES('$locations_id','$locations_name','$locations_status','$locations_type','$observer_id', '$child_id')";
if (mysqli_query($link, $query)) {
echo "<script>
document.getElementById('button-container').innerHTML =
\"<a href='index.php' class='btn-custom'>🔙 Home</a><br>Successfully added Location.\";
</script>";
} else {
echo "Error: " . mysqli_error($link);
}
}
?>
</body>
</html>