-
Notifications
You must be signed in to change notification settings - Fork 3
/
findProfile.php
168 lines (164 loc) · 6.41 KB
/
findProfile.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
<title>Find Profile - The Hub </title>
<?php
require ('core.inc.php');
include('connect.php');
if(loggedin()) {
include ('headerlogin.php');
}else {
include_once ('header.php');
}
if (isset($_GET['search_user'])&&!empty($_GET['search_user'])) {
$user = mysqli_real_escape_string($link, $_GET['search_user']);
//retrieving search data and then searching the database to see if said data exists
$sql= "SELECT * FROM registration WHERE first_name ='".$user."'";
//searching through the database column to see if first name exists, if it does exixt and it's more than 0 name, it displays all the available names on a card
$result = mysqli_query($link, $sql);
$count = mysqli_num_rows($result);
if ($count>0) {
while (@$row = mysqli_fetch_array($result)) {
echo '
<div class="container-fluid">
<div class="card-group">
<!--Card-->
<div class="card card-personal">
<!--Card content-->
<div class="card-block">
<a><h4 class="card-title">'.$row["first_name"].' '.$row["last_name"].'</h4></a>
<!--Text-->
<p class="card-text">'.$row['first_name'].'\'s expertise lie in the following fields: '.$row["Abilities"].'</p>
<hr>
<a class="card-meta"><i class="fa fa-user"></i>'.$row["PhoneNumber"].'</a>
<p class="card-meta float-right"><a href="verify.user.php?search_user='.$row['email'].'"> View Profile</a></p>
</div>
<!--/.Card content-->
</div>
<!--/.Card-->
</div><br>
<!--/Card group-->
</div>
';
}
}else {
//if the name searched for isn't found in the first name column, the search then tries with the second column and then repeats the process
$sql= "SELECT * FROM registration WHERE last_name ='".$user."'";
$result = mysqli_query($link, $sql);
$count = mysqli_num_rows($result);
//saving first algorithm...just for future refernce
/* if ($count==1) {
while (@$row = mysqli_fetch_array($result)) {
$name = $row['email'];
$_SESSION['profile'] = $name;
header ('Location: access.profile.php');
}
}*/if ($count>0) {
while (@$row = mysqli_fetch_array($result)) {
$name = $row['email'];
$_SESSION['profile'] = $name;
echo '
<div class="container-fluid">
<div class="card-group">
<!--Card-->
<div class="card card-personal">
<!--Card content-->
<div class="card-block">
<a><h4 class="card-title">'.$row["first_name"].' '.$row["last_name"].'</h4></a>
<!--Text-->
<p class="card-text">'.$row['first_name'].'\'s expertise lie in the following fields: '.$row["Abilities"].'</p>
<hr>
<a class="card-meta"><i class="fa fa-user"></i>'.$row["PhoneNumber"].'</a>
<p class="card-meta float-right"><a href="verify.user.php?search_user='.$row['email'].'"> View Profile</a></p>
</div>
<!--/.Card content-->
</div>
<!--/.Card-->
</div><br>
<!--/Card group-->
</div>
';
}
}else {
//same as above...loop continues till end
$sql= "SELECT * FROM registration WHERE email ='".$user."'";
$result = mysqli_query($link, $sql);
$count = mysqli_num_rows($result);
/* if ($count==1) {
while (@$row = mysqli_fetch_array($result)) {
$name = $row['email'];
$_SESSION['profile'] = $name;
header ('Location: access.profile.php');
}
}*/if ($count>0) {
while (@$row = mysqli_fetch_array($result)) {
$name = $row['email'];
$_SESSION['profile'] = $name;
echo '
<div class="container-fluid">
<div class="card-group">
<!--Card-->
<div class="card card-personal">
<!--Card content-->
<div class="card-block">
<a><h4 class="card-title">'.$row["first_name"].' '.$row["last_name"].'</h4></a>
<!--Text-->
<p class="card-text">'.$row['first_name'].'\'s expertise lie in the following fields: '.$row["Abilities"].'</p>
<hr>
<a class="card-meta"><i class="fa fa-user"></i>'.$row["PhoneNumber"].'</a>
<p class="card-meta float-right"><a href="verify.user.php?search_user='.$row['email'].'"> View Profile</a></p>
</div>
<!--/.Card content-->
</div>
<!--/.Card-->
</div><br>
<!--/Card group-->
</div>
';
}
}else {
$sql= "SELECT * FROM registration WHERE PhoneNumber ='".$user."'";
$result = mysqli_query($link, $sql);
$count = mysqli_num_rows($result);
/*if ($count==1) {
while (@$row = mysqli_fetch_array($result)) {
$name = $row['email'];
$_SESSION['profile'] = $name;
header ('Location: access.profile.php');
}
}*/if ($count>0) {
while (@$row = mysqli_fetch_array($result)) {
$name = $row['email'];
$_SESSION['profile'] = $name;
echo '
<div class="container-fluid">
<div class="card-group">
<!--Card-->
<div class="card card-personal">
<!--Card content-->
<div class="card-block">
<a><h4 class="card-title">'.$row["first_name"].' '.$row["last_name"].'</h4></a>
<!--Text-->
<p class="card-text">'.$row['first_name'].'\'s expertise lie in the following fields: '.$row["Abilities"].'</p>
<hr>
<a class="card-meta"><i class="fa fa-user"></i>'.$row["PhoneNumber"].'</a>
<p class="card-meta float-right"><a href="verify.user.php?search_user='.$row['email'].'"> View Profile</a></p>
</div>
<!--/.Card content-->
</div>
<!--/.Card-->
</div><br>
<!--/Card group-->
</div>
';
}
}else {
//if all the above commands have run and there's still no record, an error messasge is sent to the user
echo '<div class="col-md-4 text-center"><h5 style="color:red; font-style:bold;"> Profile does not exist. Please check the profile name and try again. Try the user\'s first name, last name, email, or phone number. Do not search all together </h5></div>';
}
}
}
}
}else {
echo '<h5 style="color:red; font-style:bold;"> Error. Please check and try again </h5>';
die();
}
include 'footer.php';
?>