/
browse_profile.php
185 lines (143 loc) · 4.59 KB
/
browse_profile.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
include "dbconnect.php";
include "members_only.php";
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/profile.css">
</head>
<body>
<div class="banner" id="banner_top">
<a href="index.php"><img src="img/logo.png" height="120" width="160" style="margin-left: 11.5%"></a>
<nav>
<a href="index.php">Home</a>
<a href="logout.php">Logout</a>
<a href="registration.php">Register</a>
<a href="">Inbox</a>
<a href="profile.php">My heydate</a>
<a href="search_results.php">Search</a>
Hello, <?php echo $_SESSION['valid_user']; ?>
</nav>
</div>
photos:
<?php
$query = 'select * from users_photo '
."where userID=".$customerID ;
$result = $db->query($query);
$num_results = $result->num_rows;
for ($i=0; $i <$num_results; $i++) {
$row = $result->fetch_assoc();
echo '<img src="users_photo/'.$row['photo'].'" height="100">';
}
?>
<section>
<?php
if(isset($_GET['customerID']))
$customerID=$_GET['customerID'];
print_basic_info($customerID, $db);
?>
description: <br/>
<p>
<?php
$query = 'select * from users_description '
."where userID=".$customerID;
$result = $db->query($query);
$Intro = NULL;
$Mate_Criteria = NULL;
$Life_Style = NULL;
while($row = $result->fetch_assoc()){
switch ($row['type']) {
case "Intro":
$Intro = $row['description'];
break;
case "Mate_Criteria":
$Mate_Criteria = $row['description'];
break;
case "Life_Style":
$Life_Style = $row['description'];
break;
default:
$Intro = $row['description'];//default type is intro
}
}
$Types = array("Intro"=>$Intro, "Mate_Criteria"=>$Mate_Criteria, "Life_Style"=>$Life_Style);
foreach($Types as $type => $type_value){
if($type_value!=NULL){
echo $type.":<br/><p>".$type_value;
}
echo "</p>";
}
// check active relation
$status_active = 'no status';
$query = 'select status from users_relationship '
."where userID1=".$_SESSION['valid_userID'].
' and userID2='.$customerID;
$result = $db->query($query);
if($result->num_rows >0 ){
$row = $result->fetch_assoc();
$status_active = $row['status'];
$query = 'Update users_relationship set statusTime=CURRENT_TIMESTAMP '
."where userID1=".$_SESSION['valid_userID'].
' and userID2='.$customerID;
}else{
$query = 'insert into users_relationship (userID1, userID2, status) '
."values (".$_SESSION['valid_userID'].','.$customerID.',"Viewed")';
}
$result = $db->query($query);
if (!$result)
echo $query." failed.";
echo 'You '.$status_active.' He/she<br/>';
// check passive relation
$status_passive = 'no status';
$query = 'select status from users_relationship '
."where userID2=".$_SESSION['valid_userID'].
' and userID1='.$customerID;
$result = $db->query($query);
if($result->num_rows >0 ){
$row = $result->fetch_assoc();
$status_passive = $row['status'];
}
echo 'He/She '.$status_passive.'You<br/>';
if($status_active=='Like'&&$status_passive=='Like')
echo 'Match!<br/>';
?>
</p>
</section>
<form action="browse_action.php?" method="post">
<input type="hidden" name="customerID" value=<?php echo $customerID; ?>>
<button type="submit" name="status_change" value= <?php
if($status_active=='Like'){
echo '"Dislike" >Dislike';
}else{
echo '"Like" >Like';
}
?></button>
</form>
<form action="browse_action.php" method="post">
<input type="hidden" name="customerID" value=<?php echo $customerID; ?>>
<textarea name="message" ows="4" cols="50" placeholder></textarea>
<input type=submit name="send" value="Send Message">
</form>
Message History:
<?php
$query= 'select * from users_message '
."where (senderID=".$_SESSION['valid_userID']." and receiverID =".$customerID.")or".
"(receiverID=".$_SESSION['valid_userID']." and senderID =".$customerID.")".
'order by time desc';
$message_history= $db->query($query);
while($row = $message_history->fetch_assoc()){
echo $row['senderID'].' '.
$row['receiverID'].' '.
$row['message'].' '.
$row['time'].'<br/>';
}
?>
<?php
include "right_record_bar.php";
?>
<footer>
Copyright © heydate.com
</footer>
</body>
</html>