Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2.     $host = "";
  3.     $user = "";
  4.     $pass = "";
  5.     $banco = "login";
  6.     $conexao = mysql_connect($host, $user, $pass) or die (mysql_error());
  7.     mysql_select_db($banco) or die (mysql_error());
  8. ?>
  9.  
  10. <html>
  11.     <head>
  12.         <title> A iniciar sessao </title>
  13.         <script type="text/javascript">
  14.             function loginsuccefully() {
  15.                 setTimeout("window.location='logado.html'", 5000);
  16.             }
  17.  
  18.             function loginfailed() {
  19.                 setTimeout("window.location='login.php'", 5000);
  20.             }
  21.         </script>
  22.     </head>
  23.     <body bgcolor="#00BFF">
  24.         <?php
  25.             $username=$_POST['email'];
  26.             $senha=$_POST['senha'];
  27.             $sql=mysql_query("SELECT * FROM usuarios WHERE email = '$email' and senha = '$senha'") or die(mysql_error());
  28.             $row=mysql_num_rows($sql);
  29.             if($row > 0) {
  30.                 session_start();
  31.                 $_SESSION['email']=$_POST['email'];
  32.                 $_SESSION['senha']=$_POST['senha'];
  33.                 echo "<script>loginsuccefully();</script>";
  34.             } else {
  35.                 echo "<center> Nome ou senha invalido! Por favor aguarde...</center>";
  36.                 echo "<script>loginfailed();</script>";
  37.             }
  38.         ?>
  39.     </body>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement