Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. if($_SERVER['REQUEST_METHOD']=="GET") {
  2. session_start();
  3. if (isset($_SESSION["user"])){
  4. header('Location: home.php');
  5. }
  6. else{
  7. http_login_page();
  8. }
  9. }
  10. else {
  11. require("dbconnection.php");
  12. $usernameQuery = $db->query("SELECT * FROM users WHERE login = '{$_POST['user']}'");
  13. $tableau = Array();
  14. $tableau = $usernameQuery->fetchArray(SQLITE3_ASSOC);
  15. if ($tableau == false){
  16. http_login_page();
  17. http_login_page_fail();
  18. }else{
  19. if ($tableau['nb_errors']==2){
  20. http_login_page();
  21. http_login_page_fail();
  22. http_login_page_warning();
  23. }else{
  24. if ($tableau['password']!="{$_POST['password']}"){
  25. $db->exec("UPDATE users SET nb_errors = nb_errors + 1 WHERE login='{$_POST["user"]}'");
  26. http_login_page();
  27. http_login_page_fail();
  28. }
  29. if ($tableau['password']=="{$_POST['password']}" and $tableau[disabled]==0 and $tableau['blocked']==0){
  30. $_SESSION['user']="{$_POST['user']}";
  31. $_SESSION['firstname']=$tableau['firstname'];
  32. $_SESSION['lastname']=$tableau['lastname'];
  33. header('Location: home.php');
  34. }
  35. }
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement