CSY2028-assignment-1/functions.php

25 lines
577 B
PHP
Raw Normal View History

2022-11-16 13:27:51 +00:00
<?php
function fetchCats() {
$server = 'mysql';
$username = 'student';
$password = 'student';
2022-11-16 19:25:32 +00:00
$schema = 'assignment1';
2022-11-16 13:27:51 +00:00
$pdo = new PDO('mysql:dbname=' . $schema . ';host=' . $server, $username, $password);
2022-11-16 19:17:35 +00:00
$stmt = $pdo->prepare('SELECT * FROM category');
2022-11-16 13:27:51 +00:00
$stmt->execute();
$cats = $stmt->fetchAll();
return $cats;
2022-11-16 19:00:51 +00:00
}
2022-11-19 15:38:26 +00:00
function adminCheck() {
if(isset($_SESSION['admin'])) {
if($_SESSION['admin'] != 'y') {
echo '<script>window.location.href = "../index.php";</script>';
}
}
else {
echo'<script>window.location.href = "../index.php";</script>';
}
}
2022-11-16 19:00:51 +00:00
?>