Advertisement
Guest User

Untitled

a guest
Nov 24th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <form id="form1" name="form1" method="post" action="index.php">
  2. <p>Nome: <input name="email" type="text"> </p>
  3. <p>Senha: <input type="text" name="senha"> </p>
  4.  
  5. <input type="submit" name="post_back" id="button" value="Submit">
  6. </form>
  7.  
  8. <?php
  9.  
  10. session_start();
  11.  
  12. require("config.php");
  13.  
  14. if(isset($_REQUEST["post_back"])){
  15.  
  16. $tb = $conn->prepare("select id_usuario from usuario where email_usuario=:email and senha_usuario=:senha");
  17. $salt = $_POST["senha"];
  18. $custo = '08';
  19. $hash = crypt($senha, '$2a$' . $custo . '$' . $salt . '$');
  20.  
  21. $tb->bindParam(":email", $_POST["email"], PDO::PARAM_STR);
  22. $tb->bindParam(":senha", $hash, PDO::PARAM_STR);
  23. $tb->execute();
  24. $l = $tb->fetch(PDO::FETCH_ASSOC);
  25. $tb = null;
  26. if(!empty($l)){
  27.  
  28. $_SESSION["usuario"] = $l["id_usuario"]; header("Location: dados.php");
  29.  
  30. }else{
  31.  
  32. echo "<script>alert('Login Falhou');</script>";
  33.  
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement