-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.php
109 lines (73 loc) · 1.88 KB
/
data.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
//andmete salvestamine/näitamine mvp idee järgi.
//ühendan sessiooniga
require("functions.php");
//kui ei ole sisse loginud, suunan login lehele.
if(!isset($_SESSION["userId"])) {
header("Location: Login.php");
}
//kas aadressireal on logout
if(isset($_GET["logout"])) {
session_destroy();
header("Location: Login.php");
}
if(ISSET($_POST["age"]) &&
isset($_POST["varv"])){
$vanus = $_POST["age"];
$varvus = $_POST["varv"];
saveEvent($vanus, $varvus);
}
$people = getAllPeople();
/*echo "<pre>";
var_dump($people);
echo "</pre>";*/
?>
<h1>Data</h1>
<p>
Tere tulemast <?=$_SESSION["userEmail"];?>!<br><br>
<a href="?logout=1">logi välja</a>
</p>
<p>
<br><br>
<form method="POST">
<input name="age" type="text" placeholder="Vanus">
<br><br>
<input name="varv" value="Värvus" type="color">
<br><br>
<input type="submit" value = "Sisesta andmed">
</form>
</p>
<h2>Arhiiv</h2>
<?php
$html = "<table>";
$html .= "<tr>";
$html .= "<th>ID</th>";
$html .= "<th>Vanus</th>";
$html .= "<th>Värv</th>";
$html .="</tr>";
foreach ($people as $p) {
$html .= "<tr>";
$html .= "<td>".$p->id."</td>";
$html .= "<td>".$p->age."</td>";
$html .= "<td>".$p->Color."</td>";
$html .= "<td><a href='edit.php?id=".$p->id."'>edit.php</a></td>";
$html .= "</tr>";
}
$html .= "</table>";
echo $html;
?>
<h2>Midagi huvitavat</h2>
<?php
foreach($people as $p) {
$style = "
background-color:".$p->Color.";
width: 40px;
height: 40px;
border-radius: 20px;
text-align: center;
line-height: 40px;
float: left;
margin: 5px;
";
echo "<p style = '".$style."'>".$p->age."</p>";
}