Guest User

Untitled

a guest
Feb 12th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: user
  5. * Date: 2019-02-11
  6. * Time: 08:40
  7. */
  8.  
  9. class Hack
  10. {
  11. protected $user;
  12. protected $attempt;
  13. protected $authentication;
  14.  
  15. private function validate($data)
  16. {
  17.  
  18. }
  19.  
  20. private function connection()
  21. {
  22. $con = new PDO('hack_css_bd', 'brood', 'fuck');
  23. $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  24.  
  25. return $con;
  26. }
  27.  
  28.  
  29. private function prepareStatement($sql){
  30. return $this->connection()->prepare($sql);
  31. }
  32.  
  33. public function auth($user)
  34. {
  35.  
  36. $sql = "SELECT * FROM users WHERE username = :username AND password = :password LIMIT 1";
  37. $stmt =$this->prepareStatement($sql);
  38. $stmt->bindValue( "username", $this->username, PDO::PARAM_STR );
  39. $stmt->bindValue( "password", hash("sha256", $this->password . $this->salt), PDO::PARAM_STR );
  40. if($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
  41. session_start();
  42. //**
  43. return true;
  44. }else{
  45. return false;
  46. }
  47.  
  48. }
  49.  
  50. public function searchBook($fromPost){
  51. $this->validate($fromPost);
  52. $value=$fromPost->someValue;
  53. $query =$this->prepareStatement('SELECT id,name FROM table WHERE name LIKE ? LIMIT 10');
  54. $query->bindValue(1, "%$value%", PDO::PARAM_STR);
  55. if (!$query->rowCount() == 0) {
  56.  
  57. }
  58. }
  59.  
  60. }
Add Comment
Please, Sign In to add comment