-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddCategory.php
More file actions
45 lines (42 loc) · 1.16 KB
/
addCategory.php
File metadata and controls
45 lines (42 loc) · 1.16 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
<?php
require 'admin.php';
/*include 'connection.php';
$conn = connect();
session_start();
if (isset($_SESSION["uname"])) {
$store = $_SESSION["uname"];
}
else {
header("Location: officeLogin.php");
}*/
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Add Category</title>
<link rel="stylesheet" href="addCategory.css">
</head>
<body>
<div class="bod">
<form class="add" method="post">
<input type="text" name="category" placeholder="Food Category">
<input type="submit" name="create" value="CREATE">
<?php
if (isset($_POST["create"])) {
$cat = $_POST["category"];
$_SESSION["category"]=$cat;
$user = $_SESSION["uname"];
$check = mysqli_query($conn,"SELECT category From category WHERE category='$cat'");
if (mysqli_num_rows($check)==0) {
$sql = mysqli_query($conn,"INSERT INTO category(category, add_by) VALUES('$cat','$user')");
}
else {
echo $_SESSION["category"]." added once!";
}
}
?>
</form>
</div>
</body>
</html>