Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2. include("includes/config.php");
  3.  
  4. class Login {
  5.  
  6. private $db;
  7. private $us;
  8. private $pw;
  9.  
  10. /* connect to database */
  11. function __construct() {
  12. $this->db = new mysqli(DBHOST, DBUSER, DBPASS, DBDATABASE);
  13. if($this->db->connect_errno > 0)
  14. {
  15. die("Fel vid anslutning: " . $this->db->connect_error);
  16. }
  17. }
  18.  
  19.  
  20. /* Login */
  21. public function checkInput($username, $password)
  22. {
  23. $username = $this->db->real_escape_string($username);
  24. $password = $this->db->real_escape_string($password);
  25.  
  26. $query ="SELECT * FROM users WHERE username = '$username' and password = '$password'";
  27.  
  28. $result = $this->db->query($query);
  29.  
  30. mysqli_query($this->db, $query);
  31.  
  32. if(mysqli_num_rows($result) > 0){
  33. header("Location: control.php");
  34. }
  35. else {
  36. echo ("<p>Någonting gick fel</p>");
  37. }
  38. mysqli_close($db);
  39.  
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement