Jump to content
Fórum Script Brasil
  • 0

Tela do Login não mostra alert


eduehi
 Share

Question

Bom dia Pessoal, estou fazendo uma tela de login, mas não consigo apresentar um "alert" em caso de falha. Segue meu código.

<?php

class Acesso{
      public function run(){
          
          $html = '';

          Session::setValue('erro','');

          switch (App::getAction()) {
              case 'logout':
                  $this->logout();
                  break;
          
              case 'validar':
                  $this->validar();
                  break;

              default:
                  $html = $this->login();
                  break;
          }
          
          return $html;
          
      }
      public function login(){
      
            $html_login= new Html();
            $html=$html_login->load( 'view/login.html');
            
            return $html;
          
      }
     
      public function validar(){
     
          $dados = Connection::select( "SELECT login,senha,departamento_id FROM usuario WHERE login='".$_POST['usuario']."'" );
          Connection::close();
          
          foreach( $dados as $reg):
              if($_POST['senha']==$reg['senha']):
                    Session::setValue('logado',true);
                    Session::setValue('departamento',$reg['departamento_id']);
              else:
                    //Session::setValue('erro');
                    echo  "<script>alert('Dados inválidos!);</script>";
                    //header('location: index.php');
              endif;
          endforeach;
          
          header( 'Location: '.URL ) ;
          
      }
      
      public function logout(){
             
          Session::setValue('logado',false);
          header( 'Location: '.URL ) ;
          
      }
      
}

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.6k
    • Total Posts
      646.2k
×
×
  • Create New...