Advertisement
Guest User

Untitled

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