2022-12-30 03:25:40 +00:00
|
|
|
<?php
|
|
|
|
include "partials/header.php";
|
2024-03-29 06:36:56 +00:00
|
|
|
if(!isset($_SESSION['user_is_admin'])){
|
|
|
|
header("location: " . ROOT_URL . "logout.php");
|
|
|
|
//destroy all sessions and redirect user to login page
|
|
|
|
session_destroy();
|
|
|
|
}
|
2023-03-07 01:23:47 +00:00
|
|
|
if(isset($_GET['id'])){
|
|
|
|
$id=filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
|
|
|
|
// fetch category from database
|
|
|
|
$query="SELECT * FROM categories WHERE id=$id";
|
|
|
|
$result=mysqli_query($connection,$query);
|
|
|
|
if(mysqli_num_rows($result)==1){
|
|
|
|
$category = mysqli_fetch_assoc($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
header("location: " . ROOT_URL . "admin/manage-categories.php");
|
|
|
|
die();
|
|
|
|
}
|
2022-12-30 03:25:40 +00:00
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
<section class="form__section">
|
|
|
|
|
2023-03-07 01:23:47 +00:00
|
|
|
<div class="container form__section-container" >
|
2022-12-30 03:25:40 +00:00
|
|
|
<h2>Edit Category</h2>
|
2023-03-07 01:23:47 +00:00
|
|
|
<form action="<?= ROOT_URL ?>admin/edit-category-logic.php" method="POST">
|
|
|
|
<input type="hidden" name="id" value="<?=$category['id']?>">
|
|
|
|
<input type="text" name="title" value="<?=$category['title']?>" placeholder="Title">
|
|
|
|
<textarea rows="4" name="description" placeholder="Description"><?=$category['description']?></textarea>
|
2022-12-30 03:25:40 +00:00
|
|
|
|
2023-03-07 01:23:47 +00:00
|
|
|
<button type="submit" name ="submit" class="btn">Update Category</button>
|
2022-12-30 03:25:40 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
include "../partials/footer.php";
|
|
|
|
?>
|