-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_category.php
43 lines (38 loc) · 1.54 KB
/
edit_category.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
<?php
/*
Cole Cianflone
Nov 7th, 2022
Purpose: Script to edit a category.
*/
require("connect.php");
require("templates/header.php");
// gets id of post
$id = filter_input(INPUT_GET, "id", FILTER_SANITIZE_NUMBER_INT);
// prepare query
$query = "SELECT * FROM sneaker_category WHERE category_id = :id";
$statement = $db->prepare($query);
// bind values to insert statement
$statement->bindValue(":id", $id, PDO::PARAM_INT);
$statement->execute();
$category = $statement->fetchAll();
?>
<div class="container" id="category_to_edit" style="padding-top: 40px;">
<form action="process_category_post.php" method="post">
<fieldset>
<div class="form-group">
<p>
<label for="category_name">Category Name</label>
<input class="form-control" name="category_name" style="max-width: 300px;" id="category_name" value="<?=$category[0]['category_name']?>"/>
</p>
</div>
<div class="form-group">
<p>
<input type="hidden" name="category_id" value="<?=$_GET['id']?>" />
<input class="btn btn-success" type="submit" name="command" value="Update" />
<input class="btn btn-danger" type="submit" name="command" value="Delete" onclick="return confirm('Are you sure you wish to delete this category? It will delete any sneakers associated with it.')" />
</p>
</div>
</fieldset>
</form>
</div>
</html>