-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.php
More file actions
114 lines (68 loc) · 1.86 KB
/
Copy pathuser.php
File metadata and controls
114 lines (68 loc) · 1.86 KB
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
110
111
112
113
114
<?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"]));
}
// RIPPMENÜÜ VALIK
if ( isset($_POST["userInterest"]) &&
!empty($_POST["userInterest"])
) {
echo $_POST["userInterest"]."<br>";
saveUserInterest(cleanInput($_POST["userInterest"]));
}
$interests = getAllInterests();
?>
<h1><a href="data.php"> < tagasi</a> Kasutaja leht</h1>
<?=$msg;?>
<p>
Tere tulemast <?=$_SESSION["userEmail"];?>!
<a href="?logout=1">Logi välja</a>
</p>
<h2>Salvesta hobi</h2>
<?php
$listHtml = "<ul>";
foreach($interests as $i){
$listHtml .= "<li>".$i->interest."</li>";
}
$listHtml .= "</ul>";
echo $listHtml;
?>
<form method="POST">
<label>Hobi/huviala nimi</label><br>
<input name="interest" type="text">
<input type="submit" value="Salvesta">
</form>
<h2>Kasutaja hobid</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>