SHARE
TWEET

Untitled

a guest Jun 15th, 2017 161 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3.  
  4. if(isset($_POST['email']) && empty($_POST['email']) == false){
  5.  
  6.     $email = addslashes($POST['email']);
  7.     $senha = md5(addslashes($POST['senha']));
  8.  
  9.     $dsn = "mysql=dbname=blog;host=localhost";
  10.     $dbuser = "root";
  11.     $dbpass = "";
  12.  
  13. try {
  14.     $db = new PDO($dsn, $dbuser, $dbpass);
  15.  
  16.     $sql = $db->query("SELECT * FROM users WHERE email = '$email' AND senha = '$senha'");
  17.  
  18.     if($sql->rowCount() > 0){
  19.  
  20.         $dado = $sql->fetch();
  21.  
  22.         print_r($dado);
  23.  
  24.     $_SESSION['id'] = $dado['id'];
  25.  
  26.         header("Location: index.php");
  27.     }
  28.  
  29. } catch (PDOException $e) {
  30.     echo "Falhou: ".$e->getMessage();
  31. }
  32.  
  33. }
  34.  
  35. ?>
  36.  
  37. <h2>Pagina de Login</h2>
  38.  
  39. <form method="POST">
  40.  
  41.     E-mail:<br>
  42.     <input type="email" name="email"><br><br>
  43.  
  44.     Senha:<br>
  45.     <input type="password" name="senha"><br><br>
  46.  
  47.     <input type="submit" value="Entrar">
  48.  
  49. </form>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top