Guest User

Untitled

a guest
Oct 16th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. // login
  2.  
  3. <?php
  4. $adminUsername = "username";
  5. $adminPassword = "hash della password";
  6. $usernameAdmin = htmlspecialchars($_POST['usernameAdmin']);
  7. $passwordAdmin = htmlspecialchars(hash("sha256", $_POST['passwordAdmin']));
  8. if(isset($usernameAdmin) && ($passwordAdmin) && ($usernameAdmin === $adminUsername) && ($passwordAdmin === $adminPassword))
  9. {
  10. session_start();
  11. $_SESSION['login'] = "yes";
  12. header("Location: index.php");
  13. }
  14. else
  15. {
  16. $counter = "0";
  17. session_start();
  18. $_SESSION['counter'] = $counter++;
  19. if($counter >= "4")
  20. {
  21. print"VAI VIA LAMER!!!";
  22. }
  23. }
  24. ?>
  25.  
  26. // fine login
  27.  
  28. // il codice che va nelle pagine da proteggere
  29.  
  30. <?php
  31. if(!isset($_SESSION['login']) && ($_SESSION['login'] != "yes"))
  32. {
  33. die(header("Location: login.php"));
  34. }
  35. ?>
  36.  
  37. //fine
Add Comment
Please, Sign In to add comment