-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-region2.php
26 lines (25 loc) · 989 Bytes
/
add-region2.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
<?php
if (isset($_POST['region-name'])) {
$region_name = $_POST['region-name'];
include("select-region.php");
$counter = count($subcategories);
foreach ($subcategories as $subcategory) {
foreach ($subcategory as $value) {
if ($value != $region_name) {
$counter--;
}
}
}
if ($counter == 0) {
include("db-connection.php");
$sql = "INSERT INTO sub_category(name) VALUES ('". $region_name . "')";
if ($db->query($sql) === TRUE) {
echo "<div class='alert alert-success' role='alert'><h3 class='h4 mb-3'>🎈 Pomyślnie dodano region!</h3></div>";
} else {
echo "<div class='alert alert-danger' role='alert'><h3 class='h4 mb-3'>❌ Nie udało się dodać regionu</h3></div>";
}
mysqli_close($db);
} else {
echo "<div class='alert alert-danger' role='alert'><h3 class='h4 mb-3'>❌ Podany region już istnieje!</h3></div>";
}
}