From 2d3685838ce8b3af5fa3b616528d21bdb58d3f10 Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:03:54 +0000 Subject: [PATCH] editcategory page completed --- public/account/login.php | 4 ++-- public/account/register.php | 8 ++++---- public/admin/addCategory.php | 2 +- public/admin/editCategory.php | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/public/account/login.php b/public/account/login.php index 548129b..a44be3d 100644 --- a/public/account/login.php +++ b/public/account/login.php @@ -4,8 +4,8 @@ $pageTitle = 'iBuy - Login'; $pageContent = '

Don\'t have an account?Click here to register

Login

- - + +
'; $stylesheet = '../assets/ibuy.css'; diff --git a/public/account/register.php b/public/account/register.php index 64dc1df..918977d 100644 --- a/public/account/register.php +++ b/public/account/register.php @@ -22,10 +22,10 @@ $pageTitle = 'iBuy - Register'; $pageContent = '

Already have an account?Click here to Login

Register

- - - - + + + +
'; diff --git a/public/admin/addCategory.php b/public/admin/addCategory.php index fc28488..895c505 100644 --- a/public/admin/addCategory.php +++ b/public/admin/addCategory.php @@ -6,7 +6,7 @@ require_once '../../functions.php'; adminCheck(); $pageContent = '

Add Category

- +
'; require '../../layout.php'; diff --git a/public/admin/editCategory.php b/public/admin/editCategory.php index e69de29..af33a9e 100644 --- a/public/admin/editCategory.php +++ b/public/admin/editCategory.php @@ -0,0 +1,32 @@ + Edit Category +
+ + +
'; +require '../../layout.php'; + +if (isset($_GET['category_id'])) { + $_SESSION['cat_id'] = $_GET['category_id']; +} +else if (isset($_POST['submit'])) { + $server = 'mysql'; + $username = 'student'; + $password = 'student'; + $schema = 'assignment1'; + $pdo = new PDO('mysql:dbname=' . $schema . ';host=' . $server, $username, $password); + $stmt = $pdo->prepare('UPDATE category SET name= :cat_name WHERE category_id= :category_id'); + $values = [ + 'cat_name' => $_POST['name'], + 'category_id' => $_SESSION['cat_id'] + ]; + $stmt->execute($values); + unset($_SESSION['cat_id']); + echo ''; +} +?> \ No newline at end of file