-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdata.php
100 lines (66 loc) · 1.71 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
<?php
//et saada ligi sessioonile)
require("functions.php");
if(!isset ($_SESSION["userId"])) {
header("Location: login.php");
exit();
}
//kas kasutaja tahab välja logida
//kas aadrrssireal on logout olemas
if(isset($_GET["logout"])) {
session_destroy();
header("Location: login.php");
}
if ( isset($_POST["note"]) &&
isset($_POST["color"]) &&
!empty($_POST["note"]) &&
!empty($_POST["color"])
) {
$note = cleanInput($_POST["note"])
saveNote($note, $_POST["color"]);
}
$notes = getAllNotes();
//echo "<pre>";
//var_dump($notes);
//echo "</pre>";
?>
<h1>DATA</h1>
<p>Welcome <?=$_SESSION["userEmail"];?>!
<br><br>
<a href="?logout=1">Log Out</a>
</p>
<h1>Notes</h1>
<form method="POST">
<label>note</label><br>
<input name="note" type="text">
<br><br>
<input name="color" type="color">
<br><br>
<input type="submit" value="Save">
</form>
<h2>archive</h2>
<?php
//iga liikme kohta massiivis
foreach ($notes as $n) {
$style = "width:100px; float:left; min-height:100px; border:1px solid gray; background-color:".$n->noteColor.";";
echo "<p style=' ".$style." '>".$n->note."</p>";
}
?>
<h2 style="clear:both;">table</h2>
<?php
$html = "<table>";
$html .= "<tr>";
$html .="<th>id</th>";
$html .="<th>note</th>";
$html .="<th>color</th>";
$html .="</tr>";
foreach ($notes as $note) {
$html .= "<tr>";
$html .="<td>".$note->id."</td>";
$html .="<td>".$note->note."</td>";
$html .="<td>".$note->noteColor."</td>";
$html .="</tr>";
}
$html .= "</table>";
echo $html;
?>