-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.php
52 lines (35 loc) · 915 Bytes
/
home.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
51
<!-- this the the master controller -->
<?php
define("Direct",1);
// this constnt means I will define constant here to know if it is defined in the other pages i will load the correct script but if this constant is not defined redirect to a certain page or just exit the application
// define it here and check defined there
//require_once("views/index.php");
// Routing
$view_id = (isset($_GET['id']) && is_numeric($_GET['id'])) ? (int)$_GET["id"] : 1 ;
//echo "view id is" .$view_id;
if($view_id === 1)
{
$current_view = "index";
}
elseif($view_id === 2)
{
$current_view = "items";
}
elseif($view_id === 3)
{
$current_view = "shoppingcart";
}
else
{
$current_view = "index";
}
//Now please Empty the Get, I took what is needed and remove all other
$_GET = array();
$_POST = array();
// Serve correct view
?>
<html>
<body>
<?php require_once("views/".$current_view.".php"); ?>
</body>
</html>