Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. //checks cookies to make sure they are logged in
  2. if(isset($_COOKIE['ID_my_site']))
  3. {
  4. $username = $_COOKIE['ID_my_site'];
  5. $pass = $_COOKIE['Key_my_site'];
  6. $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
  7. while($info = mysql_fetch_array( $check ))
  8. {
  9.  
  10. //if the cookie has the wrong password, they are taken to the login page
  11. if ($pass != $info['password'])
  12. { header("Location: login.php");
  13. }
  14.  
  15. //otherwise they are shown the private page
  16. else
  17. {
  18. echo "Private Page<p>";
  19. echo "Seekret Stuff<p>";
  20. echo "<a href=logout.php>Logout</a>";
  21. }
  22. }
  23. }
  24. else
  25.  
  26. //if the cookie does not exist, they are taken to the login screen
  27. {  
  28. header("Location: login.php");
  29. }
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement