editcategory page completed

This commit is contained in:
Joshua Perry 2022-11-19 16:03:54 +00:00
parent c955912c2b
commit 2d3685838c
4 changed files with 39 additions and 7 deletions

View File

@ -4,8 +4,8 @@ $pageTitle = 'iBuy - Login';
$pageContent = '<p>Don\'t have an account?<a href=\'register.php\'>Click here to register</a></p>
<h1>Login</h1>
<form action="login.php" method="POST">
<label>Email</label> <input name="email" type="text" />
<label>Password</label> <input name="password" type="password" />
<label>Email</label> <input name="email" type="text" placeholder="john.doe@example.com"/>
<label>Password</label> <input name="password" type="password" placeholder="password"/>
<input name="submit" type="submit" value="Submit" />
</form>';
$stylesheet = '../assets/ibuy.css';

View File

@ -22,10 +22,10 @@ $pageTitle = 'iBuy - Register';
$pageContent = '<p>Already have an account?<a href=\'login.php\'>Click here to Login</a></p>
<h1>Register</h1>
<form action="register.php" method="POST">
<label>First Name</label> <input name="first_name" type="text" />
<label>Last Name</label> <input name="last_name" type="text" />
<label>Email</label> <input name="email" type="text" />
<label>Password</label> <input name="password" type="text" />
<label>First Name</label> <input name="first_name" type="text" placeholder="John"/>
<label>Last Name</label> <input name="last_name" type="text" placeholder="Doe"/>
<label>Email</label> <input name="email" type="text" placeholder="john.doe@example.com"/>
<label>Password</label> <input name="password" type="text" placeholder="password"/>
<input name="submit" type="submit" value="Submit" />
</form>';

View File

@ -6,7 +6,7 @@ require_once '../../functions.php';
adminCheck();
$pageContent = '<h1> Add Category</h1>
<form action="addCategory.php" method="POST">
<label>Name</label> <input name="name" type="text" />
<label>Name</label> <input name="name" type="text" placeholder="name"/>
<input name="submit" type="submit" value="Submit" />
</form>';
require '../../layout.php';

View File

@ -0,0 +1,32 @@
<?php
session_start();
$pageTitle = '';
$stylesheet = '../assets/ibuy.css';
require_once '../../functions.php';
adminCheck();
$pageContent = '<h1> Edit Category</h1>
<form action="editCategory.php" method="POST">
<label>Name</label> <input name="name" type="text" placeholder="name"/>
<input name="submit" type="submit" value="Submit" />
</form>';
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 '<script>window.location.href = "adminCategories.php";</script>';
}
?>