-
Notifications
You must be signed in to change notification settings - Fork 0
/
pet.php
50 lines (38 loc) · 1.31 KB
/
pet.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
44
45
46
47
48
49
50
<?php
require("classes/components.php");
require("classes/utils.php");
require("classes/pet.php");
require("classes/basket.php");
/// This must come first when we need access to the current session
session_start();;
if(!isset($_GET["id"]) || !is_numeric($_GET["id"])) {
header("Location: " . utils::$projectFilePath . "/book-list.php");
}
/**
* Checks if the request method is POST, the 'action' parameter is set to 'add' in the GET request,
*/
if(
$_SERVER["REQUEST_METHOD"] === "POST" &&
isset($GET["action"]) &&
$GET["action"] === "add"
) {
/// Redirect user from this page if they're already logged in
if(!isset($_SESSION["loggedIn"])){
header("Location: " . Utils::$projectFilePath . "/login.php");
}
/**
* Add item to basket and redirect.
*
* For some reason it doesn't redirect, so will have a look at this later on.
*/
require ("classes/basket.php");
Basket::add($GET["id"]);
header("Location: " . Utils::$projectFilePath . "/basket.php");
}
$pet = Pet::getPet($_GET["id"]); ///< Get pet's details by its ID number
$pageTitle = $pet["name_"]; ///< Set pet's name as title of the page
var_dump($pageTitle); ///< Debugging
Components::pageHeaderAlt($pageTitle, ["style"], ["mobile-nav"]);
Components::singlePet($pet);
Components::pageFooter();
?>