-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.php
93 lines (90 loc) · 2.73 KB
/
page.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
<?php
class page {
public $pageBody;
public function get() {}
public function post() {}
public function put() {}
public function delete() {}
public function __destruct(){
echo $this->pageBody;
}
}
class homepage extends page {
public function get() {
echo '<form method="get">
First name:<br>
<input required type="text" name="firstname">
<br>
Last name:<br>
<input required type="text" name="lastname">
<br>
Email address:<br>
<input required type="test" name="email">
<br><br>
<input hidden type"add" value="true">
<button type="submit" name="page" value="table">Add User</button>
</form>
';
}
}
class table extends page {
public function get() {
$newUser = new users();
$saveUser = new users();
$deleteUser = new users();
$userTables = new users();
if(isset($_GET["firstname"]) && $_GET["firstname"] != '' && isset($_GET["lastname"]) && $_GET["lastname"] != '' && isset($_GET["email"]) && $_GET["email"] != '') {
$newUser->addUser($_GET["firstname"], $_GET["lastname"], $_GET["email"]);
}
if($_GET["save"] === "true"){
$saveUser->updateUser($_GET["email"], $_GET["firstname"], $_GET["lastname"]);
}
elseif($_GET["delete"] === "true"){
$deleteUser->deleteUser($_GET["email"]);
}
echo' <head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 15px;
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<td>Firstname</td>
<td>Lastname</td>
<td>Email</td>
</tr>';
$userTables->userTable();
echo' </table>
</body>
';
}
}
class edit extends page {
public function get() {
echo '<form method="get">
First name:<br>
<input type="text" name="firstname" value='.$_GET["first"].'>
<br>
Last name:<br>
<input type="text" name="lastname" value='.$_GET["last"].'>
<br><br>
<input hidden name="save" value="true">
<input hidden name="email" value='.$_GET["email"].'>
<button type="submit" name="page" value="table">Save</button>
</form>
<form method="get">
<input hidden name="delete" value="true">
<input hidden name="email" value='.$_GET["email"].'>
<button type="submit" name="page" value="table">Delete</button>
</form>
';
}
}
?>