2022-11-19 15:38:26 +00:00
|
|
|
<?php
|
|
|
|
|
session_start();
|
|
|
|
|
$pageTitle ='iBuy - Add Category';
|
|
|
|
|
$stylesheet = '../assets/ibuy.css';
|
|
|
|
|
require_once '../../functions.php';
|
2022-11-20 21:33:42 +00:00
|
|
|
adminCheck(); //checks to see if user is logged in as admin
|
2022-11-19 15:38:26 +00:00
|
|
|
$pageContent = '<h1> Add Category</h1>
|
|
|
|
|
<form action="addCategory.php" method="POST">
|
2022-11-19 16:03:54 +00:00
|
|
|
<label>Name</label> <input name="name" type="text" placeholder="name"/>
|
2022-11-19 15:38:26 +00:00
|
|
|
<input name="submit" type="submit" value="Submit" />
|
|
|
|
|
</form>';
|
|
|
|
|
require '../../layout.php';
|
|
|
|
|
|
|
|
|
|
if (isset($_POST['submit'])) {
|
2022-11-20 13:20:58 +00:00
|
|
|
$pdo = startDB();
|
2022-11-19 15:38:26 +00:00
|
|
|
$stmt = $pdo->prepare('INSERT INTO category(name)
|
|
|
|
|
VALUES(:name)');
|
|
|
|
|
$values = [
|
|
|
|
|
'name' => $_POST['name']
|
|
|
|
|
];
|
|
|
|
|
$stmt->execute($values);
|
2022-11-20 21:33:42 +00:00
|
|
|
echo '<script>window.location.href = "adminCategories.php";</script>'; //redirect
|
2022-11-19 15:43:06 +00:00
|
|
|
}
|
|
|
|
|
?>
|