-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemberprofile.php
139 lines (122 loc) · 4.57 KB
/
memberprofile.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
135
136
137
138
139
<?php
include './includes/header.php';
session_start();
$DB_DSN = 'localhost';
$DB_USER = 'root';
$DB_PASSWORD = '';
$DB_NAME = 'matcha2';
//connect to the newly created database
try {
$conn = new PDO("mysql:host=$DB_DSN;dbname=$DB_NAME", $DB_USER, $DB_PASSWORD);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
///insert record into views + 1popularity
try{
$sql = $conn->prepare(" INSERT IGNORE INTO viewstats (user1,user2) VALUES (:userID,:viewersID)");
$sql->bindParam(':userID', $_GET['user']);
$sql->bindParam(':viewersID', $_SESSION['id']);
$sql = $conn->prepare("UPDATE userProfile SET popularity=popularity+1 WHERE userId={$_GET['user']}");
// var_dump($sql);
// print_r($sql.'yooooo');
// $sql->bindParam(':sports', $_POST['sports']);
$sql->bindParam(':userId', $_GET['user']);
$sql->execute();
$sql->execute();
}catch(Exception $e)
{
echo 'Error: ' . $e->getMessage();
}
// $sql = $conn->prepare("UPDATE userProfile SET popularity=popularity+1 WHERE userId={$_GET['uid']}");
// $sql->execute();
// $q = "UPDATE userProfile SET popularity=:popularity+1 WHERE userId={$_GET['uid']}";
$sql = $conn->prepare("UPDATE userProfile SET popularity=popularity+1 WHERE userId=:userId");
// var_dump($sql);
// print_r($sql.'yooooo');
// $sql->bindParam(':sports', $_POST['sports']);
$sql->bindParam(':userId', $_GET['user']);
$sql->execute();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="hacker-list">
<input class="search" />
<!-- <span class="sort" data-sort="name">Sort by name</span>
<span class="sort" data-sort="city">Sort by area</span>
<span class="sort" data-sort="age">Sort by age</span>
<span class="sort" data-sort="gender">Sort by gender</span>
<span class="sort" data-sort="sexpref">Sort by sexpref</span>
<span class="sort" data-sort="interest">Sort by interest</span> -->
<ul class="list">
<?php
// $userprofiles = $dbh->query("SELECT * FROM users JOIN userprofile on users.id = userprofile.userId JOIN interestTags on users.id = interesttags.userID WHERE interestTags.interest IN('travel')")->fetch();
$uid = $_GET['user'];
// $stmt = $dbh->query("SELECT * FROM users JOIN userprofile on users.id = userprofile.userId JOIN interestTags on users.id = interesttags.userID WHERE users.id =".$uid);
$stmt = $conn->query("SELECT * FROM users JOIN userprofile on users.id = userprofile.userId JOIN interestTags on users.id = interesttags.userID WHERE users.id =".$uid);
$skipthisID = 0;
while ($row = $stmt->fetch()) {
echo '<li><p>INTERESTS:</p>';
if($skipthisID == $row['id']){
// echo '<p>'.$row['interest'].'</p>';
continue;
}
echo '<h3 class="name">'.$row['username'].'</h3>
<p>PICTURE</p>
<p class="age">'.$row['age'].'</p>
<p class="gender">'.$row['gender'].'</p>
<p class="sexpref">'.$row['sexpref'].'</p>
<p class="interest">'.$row['interest'].'</p>
<p class="city">'.$row['area'].'</p>
<p> BIO:'.$row['bio'].'</p>
<p> lastLogin:'.$row['lastLogin'].'</p>
<p> onlineStatus:'.$row['onlineStatus'].'</p>
</li>';
}
///echo like/unlike button button
$user1 = $_SESSION['id'];
$user2 = $uid;
$params = $user1.','.$user2;
$stmt = $conn->query("SELECT * FROM likes WHERE user1 IN(".$params.") AND user2 IN(".$params.")");
// $row = $stmt->fetchAll();
$found = 0;
if(count($stmt->fetchAll(PDO::FETCH_ASSOC)) < 1)
{
echo "<a href='like.php?uid=$uid'>LIKE</a>";
exit();
}
while($row = $stmt->fetch()){
//if()
if($row['user1'] == 9/*$_SESSION['id']*/)
{
echo "<a href='?unlike=$uid'>UNLIKE</a>";
break;
}else{
echo "<a href='?like=$uid'>LIKE BACK</a>";
break;
}
// else if ($stmt->rowCount() == 2){
// echo "<a href='chat.php?user2=$uid'>OPEN CHAT</a>";
// }
}
?>
</ul>
</div>
</body>
<script src="list.min.js"></script>
<script>
var options = {
valueNames: [ 'name', 'city', 'age', 'gender', 'sexpref', 'interest' ]
};
var hackerList = new List('hacker-list', options);
</script>
</html>