-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_bladder.php
71 lines (62 loc) · 2.56 KB
/
add_bladder.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
<?php
include './include/check_login.php';
include './include/connection.php';
include_once 'include/admin-main.php';
include('access_control.php');
$addProductMsg = '';
// Add Product Form Handling
if (isset($_POST['add_bladder'])) {
$bladder_name = $_POST['bladder_name'];
// Check if the bladder already exists
$checkQuery = mysqli_query($con, "SELECT * FROM bladder WHERE bladder_name = '$bladder_name'");
$rowCount = mysqli_num_rows($checkQuery);
if ($rowCount > 0) {
$addProductMsg = "<p id='addProductMsg' style='color: red;font-size: medium;text-align: center;'>Bladder already exists</p>";
} else {
// Insert into bladder table
$insertBladderProductQuery = "INSERT INTO bladder (bladder_name) VALUES ('$bladder_name')";
if (mysqli_query($con, $insertBladderProductQuery)) {
$addProductMsg = "<p id='addProductMsg' style='color: green;font-size: medium;text-align: center;'>Bladder added successfully</p>";
} else {
$addProductMsg = "<p id='addProductMsg' style='color: red;font-size: medium;text-align: center;'>Failed to add bladder</p>";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Bladder</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script>
setTimeout(function () {
document.getElementById('addProductMsg').style.display = 'none';
}, 1500); // 1.5 seconds
</script>
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card mt-5">
<div class="card-header">
<h2>Add Bladder</h2>
</div>
<div class="card-body">
<?php echo $addProductMsg; ?>
<form action="" method="post">
<div class="form-group">
<label for="bladder_name">Bladder Name</label>
<input type="text" name="bladder_name" id="bladder_name" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary" name="add_bladder">Add Bladder</button>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>