karlokokkak

Untitled

Mar 29th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. include("connect.php");
  2.  
  3. $output = '';
  4.  
  5. if(isset($_POST['search'])) {
  6.     if (empty($_POST["searchh"])) {
  7.         echo"You didn't enter anything . ";
  8.     }
  9.     else  {
  10.         $searchq = $_POST['searchh'];
  11.         $searchq = preg_replace("#[^0-9a-z]#i", "",$searchq);
  12.  
  13.         $searchq = mysqli_real_escape_string($conn, $_POST['searchh']);
  14.         $query = mysqli_query($conn ,"SELECT * FROM users WHERE username LIKE '%$searchq%'") or die("Could not search");    
  15.         $count = mysqli_num_rows($query);
  16.  
  17.         if($count == 0){
  18.             echo "User does not exists";
  19.         }
  20.         else {
  21.             while($row = mysqli_fetch_array($query)) {
  22.                 $username = $row['username'];
  23.                 $id = $row['id'];
  24.                 $output .= '<a href="home.php?username='.$username.'" >'. '<div>' .$username. '</div>' .'</a>';
  25.             }
  26.         }    
  27.     }
  28. } else {
  29. echo"Not working";
  30.  
  31. }
Add Comment
Please, Sign In to add comment