Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form name="loginform" method="post" action="userauthentication.php">
- <div align="center"><p>Email: <input type="text" name="email"><br><br>
- Senha: <input type="password" name="senha"><br><br></p>
- <input type="submit" value="Logar"></div>
- </form>
- <?php
- $host = "localhost";
- $user = "root";
- $pass = "";
- $banco = "cadastro";
- $conexao = mysql_connect($host, $user, $pass) or die (mysql_error());
- mysql_select_db($banco) or die (mysql_error());
- ?>
- <html><head><title>Autenticando usuário</title>
- <script type="text/javascript">
- function loginsuccessfully(){
- setTimeout("window.location'painel.php'", 5000);
- }
- function loginfailed(){
- setTimeout("window.location'login.php'",5000)
- }
- </script>
- </head><body>
- <?php
- $email=$_POST['email'];
- $senha=$_POST['senha'];
- $sql = ("SELECT * FROM usuarios WHERE email = '$email' and senha = '$senha'")
- $row = mysql_num_rows($sql);
- if($row > 0) {
- session_start();
- $_SESSION['email']=$_POST['email'];
- $_SESSION['senha']=$_POST['senha'];
- echo "<center>Você foi logado! Aguarde um instante.</center>"
- echo "<script>loginsuccessfully()</script>";
- }
- else {
- echo "<center>Nome de usuário ou senha inválidos, aguarde um instante.</center>";
- echo "<script>loginfailed()</script>"
- }
- ?>
- </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement