I wanted to put an alert on my login screen

1

I wanted it when I hit the login and my password or registration, did not match what is not on the bank of some alert. here is the modelUser

<?php
include 'usuarios/usuario.php';

class ModelUsuario{

    public function adicionar(){
        include 'usuarios/bd.php';

        $query = "INSERT INTO usuarios (matricula, senha) 
              VALUES (:matricula, :senha)";

        $statement = $connection->prepare($query);

        $valores = array();
        $valores[':matricula'] = $usuario->getMatricula();
        $valores[':senha'] = $usuario->getSenha();


        $result = $statement->execute($valores);


    }

    public function editar(){

    }

    public function remover(){

    }


   public function autenticar($matricula, $senha){
        include 'usuarios/bd.php';


        $query = "SELECT nome, id FROM usuario WHERE matricula=:matricula and senha=:senha";

        $statement = $connection->prepare($query);

        $valores = array();
        $valores[':matricula'] = $matricula;
        $valores[':senha'] = $senha;


        $result = $statement->execute($valores);


        $result = $statement->fetchAll();



        return $result;

    }




}

Here Is My Controller

<?php 
include 'usuarios/modelUsuario.php';

//se clicou no botão
if (isset($_POST['login'])){

    $modelo = new ModelUsuario();


    $resultado = $modelo->autenticar( ($_POST['matricula']), ($_POST['senha']) );
    if(! empty($resultado) ){
      // redirecionar para index2
      header("location: http://localhost/projeto/aluno.php"); 
    }

}





?>

Here is my form

<form  method="POST" action ="login.php" name="for">
            <div class="form-group">
              <div class="form-label-group">
                <input type="text" id="inputEmail" name="matricula" class="form-control" placeholder="Email address" required="required" autofocus="autofocus">
                <label for="inputEmail">Matrícula</label>
              </div>
            </div>
            <div class="form-group">
              <div class="form-label-group">
                <input type="password" id="inputPassword"   name="senha" class="form-control" placeholder="Password" required="required">
                <label for="inputPassword">Senha</label>
              </div>
            </div>
            <div class="form-group">
              <div class="checkbox">
                <label>
                  <input type="checkbox" value="remember-me">
                  Lembrar senha
                </label>
              </div>
            </div>
                  <button type="submit" class="btn btn-primary btn-block" href="aluno.php" name="login">Login</button> 
                    <a href="registro.php" id="cadastro" class="d-block small mt-3">Cadastrar</a>
          </form>
    
asked by anonymous 04.10.2018 / 23:09

1 answer

-1

Put this code in PHP when you want the Alert to be displayed:

Echo "<script>alert('Menssagem');</script>";
    
04.10.2018 / 23:26