Jump to content

User Search


sean04

Recommended Posts

Hey guys,

 

I have 3 radio buttons and a textbox. I can search users by user id, screenname, or email. For some reason when I type in say 7 for a user id, nothin comes up?! like my user id is 7. any ideas? Another thing... when I search by screenname or email any of MY information doesnt come up and im not sure why. everyone else's does but mine. any help would be great! Or if anyone has a better idea that would be great too! thanks!

 

			echo"
			<form action='?SearchUser' method='post'>
			Search user by:<p/>
			<input type = 'Radio' Name ='SearchBy' value='UserID'>User ID<br/>
			<input type = 'Radio' Name ='SearchBy' value='ScreenName'>Screen Name<br/>
			<input type = 'Radio' Name ='SearchBy' value='Email'>Email<br/>
			<p/>
			<input id='info' type='text' name='info' /><p/>
			<input type='submit' name='submit' value='Search'/>
			</form>";


			//make picture the profile picture
				if(isset($_GET['SearchUser'])) {
					$searchBy = $_POST['SearchBy'];
					$userInfo = htmlspecialchars(mysql_real_escape_string($_POST['info']));

					if($searchBy == "UserID"){
						$searchUser = mysql_query("SELECT * FROM viewInformation WHERE UserID LIKE '".$userInfo."%'")or die(mysql_error());
						$seachUserCount = mysql_fetch_array($searchUser);

						if(mysql_num_rows($searchUser) == 0){
							echo"No Users Found";
						} else {
							while ($UserSearch = mysql_fetch_array($searchUser)) 
							{
							echo "$UserSearch[screen_Name]<br/>";
							}
						}

					}
					else if($searchBy == "ScreenName"){

					$searchUser = mysql_query("SELECT * FROM viewInformation WHERE ScreenName LIKE '".$userInfo."%'")or die(mysql_error());
						$seachUserCount = mysql_fetch_array($searchUser);

						if(mysql_num_rows($searchUser) == 0){
							echo"No Users Found";
						} else {
							while ($UserSearch = mysql_fetch_array($searchUser)) 
							{
							echo "$UserSearch[screen_Name]<br/>";
							}
						}


					}

					else if($searchBy == "Email"){

					$searchUser = mysql_query("SELECT * FROM viewInformation WHERE EmailAddress LIKE '".$userInfo."%'")or die(mysql_error());
						$seachUserCount = mysql_fetch_array($searchUser);

						if(mysql_num_rows($searchUser) == 0){
							echo"No Users Found";
						} else {
							while ($UserSearch = mysql_fetch_array($searchUser)) 
							{
							echo "$UserSearch[Email_Address]<br/>";
							}
						}


					}
				}

Link to comment
https://forums.phpfreaks.com/topic/208603-user-search/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.