editcategory page completed
This commit is contained in:
parent
c955912c2b
commit
2d3685838c
|
|
@ -4,8 +4,8 @@ $pageTitle = 'iBuy - Login';
|
||||||
$pageContent = '<p>Don\'t have an account?<a href=\'register.php\'>Click here to register</a></p>
|
$pageContent = '<p>Don\'t have an account?<a href=\'register.php\'>Click here to register</a></p>
|
||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
<form action="login.php" method="POST">
|
<form action="login.php" method="POST">
|
||||||
<label>Email</label> <input name="email" type="text" />
|
<label>Email</label> <input name="email" type="text" placeholder="john.doe@example.com"/>
|
||||||
<label>Password</label> <input name="password" type="password" />
|
<label>Password</label> <input name="password" type="password" placeholder="password"/>
|
||||||
<input name="submit" type="submit" value="Submit" />
|
<input name="submit" type="submit" value="Submit" />
|
||||||
</form>';
|
</form>';
|
||||||
$stylesheet = '../assets/ibuy.css';
|
$stylesheet = '../assets/ibuy.css';
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@ $pageTitle = 'iBuy - Register';
|
||||||
$pageContent = '<p>Already have an account?<a href=\'login.php\'>Click here to Login</a></p>
|
$pageContent = '<p>Already have an account?<a href=\'login.php\'>Click here to Login</a></p>
|
||||||
<h1>Register</h1>
|
<h1>Register</h1>
|
||||||
<form action="register.php" method="POST">
|
<form action="register.php" method="POST">
|
||||||
<label>First Name</label> <input name="first_name" type="text" />
|
<label>First Name</label> <input name="first_name" type="text" placeholder="John"/>
|
||||||
<label>Last Name</label> <input name="last_name" type="text" />
|
<label>Last Name</label> <input name="last_name" type="text" placeholder="Doe"/>
|
||||||
<label>Email</label> <input name="email" type="text" />
|
<label>Email</label> <input name="email" type="text" placeholder="john.doe@example.com"/>
|
||||||
<label>Password</label> <input name="password" type="text" />
|
<label>Password</label> <input name="password" type="text" placeholder="password"/>
|
||||||
<input name="submit" type="submit" value="Submit" />
|
<input name="submit" type="submit" value="Submit" />
|
||||||
</form>';
|
</form>';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ require_once '../../functions.php';
|
||||||
adminCheck();
|
adminCheck();
|
||||||
$pageContent = '<h1> Add Category</h1>
|
$pageContent = '<h1> Add Category</h1>
|
||||||
<form action="addCategory.php" method="POST">
|
<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" />
|
<input name="submit" type="submit" value="Submit" />
|
||||||
</form>';
|
</form>';
|
||||||
require '../../layout.php';
|
require '../../layout.php';
|
||||||
|
|
|
||||||
|
|
@ -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>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue