Advertisement
Guest User

Untitled

a guest
Jan 10th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 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. if($row['Password']==$password)
  20. {
  21. $_SESSION['username']=$username;
  22. if($check=='1')
  23. {
  24. $keep=$check;
  25. setcookie("keepme",$keep,time()+3600*24*15);
  26. setcookie("keepuser",$username,time()+3600*24*15);
  27. }
  28. if($username=="admin")
  29. header("Location: home_admin.php");
  30. else
  31. header("Location: home.php");
  32. exit;
  33. }
  34. else
  35. {
  36. header("Location: index.php?wrong=2");
  37. exit;
  38. }
  39. }
  40. }
  41. session_destroy();
  42. header("Location: index.php?wrong=1");
  43. exit;
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement