Advertisement
Guest User

Untitled

a guest
Mar 28th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <form name="loginform" method="post" action="userauthentication.php">
  2. <div align="center"><p>Email: <input type="text" name="email"><br><br>
  3. Senha: <input type="password" name="senha"><br><br></p>
  4. <input type="submit" value="Logar"></div>
  5. </form>
  6.  
  7. <?php
  8. $host = "localhost";
  9. $user = "root";
  10. $pass = "";
  11. $banco = "cadastro";
  12. $conexao = mysql_connect($host, $user, $pass) or die (mysql_error());
  13. mysql_select_db($banco) or die (mysql_error());
  14. ?>
  15.  
  16. <html><head><title>Autenticando usuário</title>
  17. <script type="text/javascript">
  18. function loginsuccessfully(){
  19. setTimeout("window.location'painel.php'", 5000);
  20. }
  21. function loginfailed(){
  22. setTimeout("window.location'login.php'",5000)
  23. }
  24. </script>
  25. </head><body>
  26.  
  27. <?php
  28. $email=$_POST['email'];
  29. $senha=$_POST['senha'];
  30. $sql = ("SELECT * FROM usuarios WHERE email = '$email' and senha = '$senha'")
  31. $row = mysql_num_rows($sql);
  32. if($row > 0) {
  33. session_start();
  34. $_SESSION['email']=$_POST['email'];
  35. $_SESSION['senha']=$_POST['senha'];
  36. echo "<center>Você foi logado! Aguarde um instante.</center>"
  37. echo "<script>loginsuccessfully()</script>";
  38. }
  39. else {
  40. echo "<center>Nome de usuário ou senha inválidos, aguarde um instante.</center>";
  41. echo "<script>loginfailed()</script>"
  42. }
  43. ?>
  44.  
  45. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement