Guest User

Untitled

a guest
Dec 30th, 2016
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. public function controllo_login() {
  2. if($_SESSION['username']) {
  3. header("Location: ../me.php");
  4. exit;
  5. }
  6.  
  7. if(!isset($_GET['login'])) {
  8. $_GET['login'] = 'no';
  9. }
  10.  
  11. if($_GET['login'] == "ok") {
  12. /*FILTRO LE VARIABILI & CRYPTO LA PASSWORD PER MAGGIORE SICUREZZA IN USCITA DAL FORM */
  13. $username = $this->Filtro($_POST["username"]);
  14. $password = $this->Filtro($_POST['password']);
  15. $password = sha1($password);
  16.  
  17. if(isset($username, $password)) {
  18. /* ESEGUO LE QUERY UTILI */
  19. $query = $this->conn->prepare("SELECT * FROM users WHERE username = :nomeutente");
  20. $query->execute(array('nomeutente' => $username));
  21. $num_usr = $query->rowCount();
  22. $fields_usr = $query->fetch(PDO::FETCH_ASSOC);
  23. $query2 = $this->conn->prepare("SELECT * FROM bans WHERE value = :nomeutente");
  24. $query2->execute(array('nomeutente' => $username));
  25. $num_ban = $query2->rowCount();
  26. if ($num_usr == 0) {
  27. $err= "L'utente non esiste!";
  28. } elseif($num_ban >= 1) {
  29. $err= "Sei stato bannato!";
  30. } elseif($password != $fields_usr['password']) {
  31. $err= "Password non corretta!";
  32. } elseif($password == $fields_usr['password']) {
  33. $_SESSION['username'] = $fields_usr['username'];
  34. $_SESSION['password'] = $fields_usr['password'];
  35. header('location: ../me.php');
  36. exit;
  37. }
  38. }
  39. echo '<center><div id="errore">'.$err.'</div></center>';
  40. }
  41. }
Add Comment
Please, Sign In to add comment