Imprimir Alert PHP

Asked

Viewed 300 times

-1

Good staff as I can print the contents of something php in a div for example : I have a login area , if the user data is wrong I want to print a div with Alert (with bootstrap) on the same page. I have this validation in php but I want you to show me in a div

follows codes

login

         <form class="login-form" method="POST" action="pg/logar.php">
  <input required type="text" name="f_usuario" placeholder="Usuario"/>
  <input required type="password" name="f_senha" placeholder="Senha"/>
  <button type="submit">Logar</button>

log in.php

     if($linhas > 0){
    $_SESSION['usuario'] = $usuario;
    $_SESSION['senha'] = $senha;
    header("Location:../logado.php");
   }else{
    echo "Dados Digitados Incorretos";
   }
  • 2

    If your question is different from the one indicated in the closing, you can click [Edit] and add relevant parts that differentiate the problem. If they are problems with solutions other than those pointed out in the link, you can edit and leave a comment to consider the reopening in the question.

1 answer

1

Try it like this:

echo '<div id="alert">Dados Digitados Incorretos</div>';
  • i need my function to log in it send incorrect typed data to a div Alert on the login page

  • Well, if I understand you are two different pages: one html, and the other php. If you want your php page’s Alert to be shown in your html it gets a little complicated. What can you do to create the page you want to get echo, in php instead of html, and require your php... so when the error occurs Alert will be displayed normally as a div as in the reply...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.