Guest User

Untitled

a guest
Apr 4th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. class user
  2. {
  3. /// User Login
  4. public function logIn($user,$password)
  5. {
  6. $counter =0;
  7. $counter++;
  8.  
  9. $con = new mysqli("localhost","root","","animal");
  10. $sql = "SELECT * FROM users WHERE username= '$user' AND password='$password'";
  11. $result = $con->query($sql);
  12. $count = mysqli_num_rows($result);
  13. $name = $result->fetch_row();
  14. if ($count===1)
  15. {
  16. session_start();
  17. $_SESSION['username'] = $name[0];
  18. $_SESSION['password'] = $name[1];
  19. $_SESSION['counter']=$name[2];
  20.  
  21.  
  22. Header ("Location:home.php");
  23.  
  24.  
  25. return true;
  26. }
  27. else
  28. {
  29. session_start();
  30.  
  31. $_SESSION['counter']++;
  32. if($_SESSION['counter'] >2)
  33. {
  34.  
  35.  
  36. echo 'you have had too Many wrong tries';
  37.  
  38. }
  39.  
  40. }
  41.  
  42.  
  43. }
  44.  
  45. //counter
  46. public function counter()
  47. {
  48. $con = new mysqli("localhost","root","","animal");
  49. $find_counts = mysqli_query("SELECT * FROM users");
  50. while($row =mysqli_fetch_assoc($find_counts)){
  51. $current_counts = $row['visits'];
  52. $new_count = $current_counts + 1;
  53. $update_count = mysqli_query("UPDATE `animal`. `users` SET `visits`= $new_count");
  54. }
  55.  
  56.  
  57. }
  58. }
  59. ?>
Add Comment
Please, Sign In to add comment