Advertisement
Guest User

autenticacao.class.php

a guest
Aug 6th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1.  
  2. <?php
  3. class autenticacao extends conexao {
  4. private $conexao;
  5. public function __construct(){
  6. parent::__construct();
  7. }
  8. public function signIn($email,$senha) {
  9. $sql = $this->conexao->query("SELECT * FROM usuarios WHERE email = '$email' AND senha = '$senha'");
  10. if ($sql->num_rows==1){
  11. while($linha = $sql->fetch_array()) {
  12. $email = $linha['nome'];
  13. $acessos = $linha['acessos']+1;
  14. }
  15. $ip=$_SERVER["REMOTE_ADDR"];
  16. $sql = $this->conexao->prepare("UPDATE usuarios SET acessos = ?, ip = ? WHERE email = ?");
  17. $sql->bind_param('iss',$acessos,$ip,$email);
  18. $sql->execute();
  19. $_SESSION["autenticado"]=$email;
  20. $_SESSION["usuario"]=$email;
  21. header('location:index.php');
  22. }
  23. else {
  24. echo '<div class="warning">O usuário ou senha inserido é inválido(a)</div>';
  25. }
  26. }
  27. public function signOut() {
  28. session_destroy();
  29. header('location:index.php');
  30. }
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement