forked from kfishster/Decider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserPage.php
136 lines (93 loc) · 2.84 KB
/
userPage.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html lang="en">
<head>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<title>Decidr</title>
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1 style="text-align: center;">Hey,
<?php
include('./cookies.php');
$id = $_POST['id'];
$email = $_POST['email'];
$name = $_POST['name'];
$nameArray = explode(' ', $name);
set_cookie($id);
echo $nameArray[0].'!';
?>
</h1>
<br>
<div class="container-fluid">
<div class="row-fluid">
<div class="span4">
<div class="well">
<ul class="nav nav-list" id="eventList">
<li class="nav-header" id="getUserID" userID="<?php global $id; echo $id;?>">My Events</li>
<?php
include('./scripts/database_connection.php');
include('./cookies.php');
global $id, $email, $name;
if(validate_cookie()) echo "done";
else echo "not logged in";
$query = 'SELECT * FROM User WHERE FBid = ' . $id;
$result = mysql_query($query) or die(mysql_error());
for($i = 0; $row = @mysql_fetch_assoc($result); $i++) {
$rows[$i] = $row;
}
if(is_null($rows))
{
//Put into database
$query = 'INSERT INTO User VALUES('.$id.', "'.$email.'" , "'.$name.'");';
$result = mysql_query($query) or die(mysql_error());
}
else
{
$query = 'SELECT * FROM Event NATURAL JOIN User NATURAL JOIN Participates WHERE FBid = ' . $id;
$result = mysql_query($query) or die(mysql_error());
// Put the result in our own rows table.
for($i = 0; $row = @mysql_fetch_assoc($result); $i++) {
$rows[$i] = $row;
}
foreach ($rows as $event) {
echo '<li><a class="openEvent" eventID="'.$event['EventID'].'">'.$event['Title'].'</a></li>';
}
}
?>
</ul>
<ul class="nav nav-list">
<li class="nav-header"></li>
<li><a id="newEvent"><b>+ Create a new event</b></a></li>
</ul>
</div>
</div>
<div class="span8" id="eventContent">
<h4>Click on an event on the left sidebar to see what all the fuss is about.</h4><br><br><p>Remember that thing that you wanted to go to? Yea, that one. Well, you still haven't decided what you're
going to be doing. Maybe you should make a new event for that and invite all your friends!</p>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$('#newEvent').click(function(){
$('#eventContent').fadeOut("slow", function(){
$(this).load('newEventForm.php', function(){
$(this).fadeIn("slow");
});
});
});
$('.openEvent').click(function(){
id = $(this).attr('eventID');
$('#eventContent').fadeOut("slow", function(){
$(this).load('eventPage.php',{id:id} ,function(){
$(this).fadeIn("slow");
});
});
});
</script>
</body>
</html>