Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php
  2. error_reporting(-1); ini_set('display_errors', 'on');
  3. Include 'db.php';  // Locates file from directory this file is in
  4.  
  5. class login {
  6. var $uname;
  7. var $pass;
  8. var $sql;
  9. var $query;
  10. var $row;
  11. var $session;
  12. var $ver;
  13. //var $uname = stripslashes($uname);    // Inject Protect
  14. //var $pass = stripslashes($pass);
  15. //var $uname = mysql_real_escape_string($uname);
  16. //var $pass = mysql_real_escape_string($pass);
  17.  
  18. public function usercheck()
  19. {
  20. $this->uname = $_POST['username'];
  21. $this->pass = $_POST['password'];
  22. $this->sql = "SELECT * FROM users WHERE username='$this->uname' and password='$this->pass'";
  23. $this->query = mysql_query($this->sql) or die(mysql_error());
  24.  
  25. if(mysql_num_rows($this->query) == 1)
  26. {
  27. $this->row = mysql_fetch_assoc($this->query); // Gets the value for each field in the row
  28. $this->session['id_user'] = $this->row['id_user']; // Store name is session var
  29. $this->session['username'] = $this->row['username']; // Store name is session var
  30. //header('Location: /site/main.php'); // Reload to update logincheck.php
  31. echo "Welcome ",$this->session['username'];
  32. }
  33. else {
  34. echo "Wrong Name Or Password";
  35. }
  36. }
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement