-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_addPublisher.php
52 lines (42 loc) · 1.75 KB
/
admin_addPublisher.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
<?php
$title = "Add Publisher";
require_once("template/header.php");
require_once("functions/database_functions.php");
$conn = db_connect();
$isAdded = false;
$publisherName = "";
$matchFound = false;
if (isset($_POST["submit"])) {
$publisherName = mysqli_real_escape_string($conn, $_POST["publisher_name"]);
$findQuery = "SELECT publisher_name FROM publisher";
$queryResult = mysqli_query($conn, $findQuery);
while ($row = mysqli_fetch_assoc($queryResult)) {
if (strtolower($publisherName) === strtolower($row["publisher_name"])) {
$matchFound = true;
break;
}
}
if ($matchFound == false) {
$publisherName = ucwords($publisherName);
$insertPublisher = "INSERT INTO publisher(publisher_name) values('$publisherName')";
$isAdded = mysqli_query($conn, $insertPublisher);
}
}
if ($isAdded) {
echo "<h2 class='text-center text-capitalize big-font-3'>Publisher \"{$publisherName}\" Added Successfully</h2><br><br><hr>";
}
if ($matchFound) {
echo "<h2 class='text-warning text-center text-capitalize big-font-3'>Publisher \"{$publisherName}\" Already Exists</h2><br><br><hr>";
}
?>
<form action="admin_addPublisher.php" class="form-horizontal" autocomplete="off" method="post">
<div class="form-group">
<label for="publisher_name" class="control-label col-md-4">Publisher Name</label>
<div class="col-md-4">
<input type="text" id="publisher_name" class="form-control" name="publisher_name"
placeholder="Rowan Atkinsen e.g" required>
</div>
<input type="submit" name="submit" value="Add Publisher" class="btn btn-primary">
</div>
</form>
<?php include("template/footer.php") ?>