Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include("connect.php");
- $output = '';
- if(isset($_POST['search'])) {
- if (empty($_POST["searchh"])) {
- echo"You didn't enter anything . ";
- }
- else {
- $searchq = $_POST['searchh'];
- $searchq = preg_replace("#[^0-9a-z]#i", "",$searchq);
- $searchq = mysqli_real_escape_string($conn, $_POST['searchh']);
- $query = mysqli_query($conn ,"SELECT * FROM users WHERE username LIKE '%$searchq%'") or die("Could not search");
- $count = mysqli_num_rows($query);
- if($count == 0){
- echo "User does not exists";
- }
- else {
- while($row = mysqli_fetch_array($query)) {
- $username = $row['username'];
- $id = $row['id'];
- $output .= '<a href="home.php?username='.$username.'" >'. '<div>' .$username. '</div>' .'</a>';
- }
- }
- }
- } else {
- echo"Not working";
- }
Add Comment
Please, Sign In to add comment