1. <?php
  2. include('../auth.php');
  3. if($_SESSION["userdata"]["acces"] != 4){
  4. header("Loaction: ../home");
  5. }
  6. ?>
  7. <!DOCTYPE html>
  8. <html>
  9. <head>
  10. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  11. <title>Usersuche Test</title>
  12. <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
  13. </head>
  14. <script type="text/javascript">
  15. $(function(){
  16. $('#search').keyup(function() {
  17. if($(this).val().length > 0) {
  18. $.get("search.php", {search: $(this).val()}, function(data) {
  19. $("#results").html(data);
  20. });
  21. }
  22. });
  23. });
  24. </script>
  25. <body>
  26. <form action="">
  27. <fieldset>
  28. <label for="filter">User: </label>
  29. <input type="text" name="search" id="search" />
  30. </fieldset>
  31. </form>
  32. <?php
  33. require_once('../db.connect.php');
  34. if($_GET['search'])
  35. $sql = mysqli_query($DBCONN, "SELECT * FROM users ORDER BY username ASC;");
  36. else
  37. $sql = mysqli_query($DBCONN, "SELECT * FROM users WHERE username LIKE '%" . $_GET['search'] . "%'
  38. ORDER BY name ASC;");
  39. while($row = mysqli_fetch_object($sql)) {
  40. echo "<br />".$row->name;
  41. }
  42. ?>
  43. <div id="results"></div>
  44. </body>
  45. </html>