Advertisement
Guest User

Untitled

a guest
Jan 10th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require("connect_db.php");
  4.  
  5. $username=$_POST['username'];
  6. $password=($_POST['password']);
  7.  
  8. $check=$_POST['remember'];
  9. $res=mysql_query("SELECT * FROM tb_user_info");
  10. while($row=mysql_fetch_array($res))
  11. {
  12. if($row['Username']==$username)
  13. {
  14. $salt = $row['Salt'];
  15. $cost = 11;
  16. $params = '$2y$' . ($cost < 10 ? 0 : '') . $cost . "$" . $salt;
  17. echo "<pre>";
  18. echo "Input: $password";
  19. echo "Salt: $salt";
  20. $password = crypt($password, $params);
  21. echo "Result: $password";
  22. $val = $row['Password'];
  23. echo "DB: $val";
  24. echo "</pre>";
  25. exit;
  26. if($row['Password']==$password)
  27. {
  28. $_SESSION['username']=$username;
  29. if($check=='1')
  30. {
  31. $keep=$check;
  32. setcookie("keepme",$keep,time()+3600*24*15);
  33. setcookie("keepuser",$username,time()+3600*24*15);
  34. }
  35. if($username=="admin")
  36. header("Location: home_admin.php");
  37. else
  38. header("Location: home.php");
  39. exit;
  40. }
  41. else
  42. {
  43. header("Location: index.php?wrong=2");
  44. exit;
  45. }
  46. }
  47. }
  48. session_destroy();
  49. header("Location: index.php?wrong=1");
  50. exit;
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement