/
data.php
110 lines (66 loc) · 2.12 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
110
<?php
require_once("functions.php");
require_once("InterestManager.class.php");
if(!isset($_SESSION['user_id'])){
header("Location: login.php");
//Ära enne suunamist midagi rohkem tee
exit();
}
if(isset($_GET["logout"])){
session_destroy();
header("Location: login.php");
exit();
}
##HALDUS##
$InterestManager = new InterestManager($mysqli, $_SESSION['user_id']);
if(isset($_GET["insert"])){
$int_name = $_GET["insert"];
$InterestManager->addInterest($int_name);
$interest_response = $InterestManager->addInterest($int_name);
}
if(isset($_GET["dropdown_interest"])) {
$InterestManager->addUserInterests($_SESSION['user_id'], $_GET["dropdown_interest"]);
$user_int_response = $InterestManager->addUserInterests($_SESSION['user_id'], $_GET["dropdown_interest"]);
var_dump($user_int_response);
}
?>
Tere, <?=$_SESSION['user_email'];?> <a href="?logout=1">Logi välja</a>
<br>
<?php if(isset($_SESSION["login_message"])): ?>
<p style="color:green;">
<?=$_SESSION["login_message"]?>
</p>
<?php
//Kustutan muutuja, et rohkem ei naidataks
unset($_SESSION["login_message"]);
endif; ?>
<?php if(isset($interest_response->success)): ?>
<p style="color:green;">
<?=$interest_response->success->message;?>
</p>
<?php elseif(isset($interest_response->error)): ?>
<p style="color:red;">
<?=$interest_response->error->message;?>
</p>
<?php endif; ?>
<h2>Lisa uus</h2>
<form method="get">
<input name="insert" type="text" placeholder="Huvi...">
<input type="submit" name="create" value="Loo huvi">
</form>
<h2>Minu huvialad</h2>
<?php if(isset($user_int_response->success)): ?>
<p style="color:green;">
<?=$user_int_response->success->message;?>
</p>
<?php elseif(isset($user_int_response->error)): ?>
<p style="color:red;">
<?=$user_int_response->error->message;?>
</p>
<?php endif; ?>
<form>
<?=$InterestManager->createDropdown();?>
<input type="submit" value="Lisa">
</form>
<h2>Loetelu</h2>
<?=$InterestManager->getUserInterests();?>