Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. class Search_Engine {
  4.  
  5. public function search(){
  6. if(isset($_POST['search'])) {
  7. $searchq = $_POST['search'];
  8. $searchq = preg_replace ("#[^0-9a-z]#i","",$searchq);
  9. $sql = "SELECT * FROM users WHERE username LIKE :ls or password LIKE :searchq or content LIKE :l";
  10. $stmt = $conn->prepare($sql);
  11. $stmt->execute();
  12. $count = $stmt->rowCount();
  13. if($count == 0) {
  14. $output = '<tr><tr>Nessun risultato trovato.</tr></td>';
  15. } else {
  16. while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
  17. $Username = $row['username'];
  18. $password = $row['password'];
  19.  
  20. $output .= '<tr><td><p>' .$username.'</p>';
  21. }
  22. }
  23. return $output;
  24. }
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement