-
Notifications
You must be signed in to change notification settings - Fork 1
/
controller.php
95 lines (93 loc) · 2.65 KB
/
controller.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
session_start();
if(isset($_GET['page'])){
$page = $_GET['page'];
} else {
$page = 'index';
}
include "database_class.php";
//Edit here to connect to your database
//Server, username, password, database in use
$database = new Database("localhost","Garry","aaaaaa","Sokoban");
if (isset($_GET['function'])){
$function = $_GET['function'];
if ($function == "Register"){
$userName = trim($_POST["username"]);
$firstName = trim($_POST['firstName']);
$lastName = trim($_POST['lastName']);
$password = trim($_POST['password']);
$email = trim($_POST['email']);
//Add checks to see if there are null values
$database->addUser($userName,$firstName,$lastName,$email,$password);
}
if ($function == "Login"){
$username = trim($_POST['username']);
$password = trim($_POST['password']);
//Add checks to see if strings are null
$database->login($username,$password);
}
if ($function == "Update"){
$userName = trim($_POST["username"]);
$firstName = trim($_POST['firstName']);
$lastName = trim($_POST['lastName']);
$email = trim($_POST['email']);
$database->updateUser($userName,$firstName,$lastName,$email);
}
if ($function == 'addGuestbookPost'){
$subject = trim($_POST['subject']);
$message = trim($_POST['message']);
$database->addGuestbookPost($subject,$message, $_SESSION['valid_user']);
}
if ($function == 'changePassword'){
$password = trim($_POST['password']);
$database->changePassword($_SESSION['valid_user'],$password);
}
}
include "website_class.php";
include "table_class.php";
include "index_code.php";
include "account_manager_code.php";
include "guestbook_code.php";
include "listOfChampions_code.php";
include "login_code.php";
include "register_code.php";
include "catalog_code.php";
include "change_password_code.php";
include "hyperlinks.php";
//Change to switch
switch ($page){
case "index":
echo $index->returnWebsite();
break;
case "account_manager":
echo $accountManager->returnWebsite();
break;
case "guestbook":
echo $guestbook->returnWebsite();
break;
case "listOfChampions":
echo $champions->returnWebsite();
break;
case "login":
echo $login->returnWebsite();
break;
case "register":
echo $register->returnWebsite();
break;
case "logout":
$database->logout();
break;
case "catalog":
echo $catalog->returnWebsite();
break;
case "catalog":
echo $catalog->returnWebsite();
break;
case "change_password":
echo $changePassword->returnWebsite();
break;
default:
echo $index->returnWebsite();
break;
}
?>