forked from brigittakannel/2.kodutoo-III-ruhm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.php
103 lines (65 loc) · 2.05 KB
/
user.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
<?php
require("functions.php");
//kui ei ole kasutaja id'd
if (!isset($_SESSION["userId"])){
//suunan sisselogimise lehele
header("Location: login.php");
exit();
}
//kui on ?logout aadressireal siis login välja
if (isset($_GET["logout"])) {
session_destroy();
header("Location: login.php");
exit();
}
$msg = "";
if(isset($_SESSION["message"])){
$msg = $_SESSION["message"];
//kui ühe näitame siis kustuta ära, et pärast refreshi ei näitaks
unset($_SESSION["message"]);
}
if ( isset($_POST["interest"]) &&
!empty($_POST["interest"])
) {
saveInterest(cleanInput($_POST["interest"]));
}
$interests = getAllInterests();
?>
<link rel="stylesheet" href="Style/data.css">
<div class="flex-container">
<header>
<h1 style="clear:both;">Hei, <?=$_SESSION["userEmail"]?>. Siin lehel saame sinust rohkem teada! </h1>
</header>
<ul>
<li><a href="user,php.php">Oled siin</a></li>
<li><a href="data.php">Kodu</a></li>
<li><a href="minu lehekülg.php">Logi välja</a></li>
</ul>
<?php
$listHtml = "<ul>";
foreach($interests as $i){
$listHtml .= "<li>".$i->interest."</li>";
}
$listHtml .= "</ul>";
echo $listHtml;
?>
<h2>Salvesta hobi</h2>
<form method="POST">
<label>Hobi/huviala nimi</label><br>
<input name="interest" type="text">
<input type="submit" value="Salvesta">
</form>
<h2>Võid valida ka olemasolevate hulgast:</h2>
<form method="POST">
<label>Hobi/huviala nimi</label><br>
<select name="userInterest" type="text">
<?php
$listHtml = "";
foreach($interests as $i){
$listHtml .= "<option value='".$i->id."'>".$i->interest."</option>";
}
echo $listHtml;
?>
</select>
<input type="submit" value="Lisa">
</form>