Advertisement
Guest User

member

a guest
Jan 12th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2. //Connects to your Database
  3. mysql_connect("localhost:3307", "root", "usbw") or die(mysql_error());
  4. mysql_select_db("auth") or die(mysql_error());
  5.  
  6. //checks cookies to make sure they are logged in
  7. if(isset($_COOKIE['ID_your_site'])){
  8.  
  9. $username = $_COOKIE['ID_your_site'];
  10. $pass = $_COOKIE['Key_your_site'];
  11. $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
  12.  
  13. while($info = mysql_fetch_array( $check )){
  14.  
  15. //if the cookie has the wrong password, they are taken to the login page
  16. if ($pass != $info['password']){
  17. header("Location: login.php");
  18. }
  19. //otherwise they are shown the admin area
  20. else{
  21.  
  22. echo "Admin Area<p>";
  23. echo "Your Content<p>";
  24. echo "<a href=logout.php>Logout</a>";
  25. }
  26. }
  27. }
  28.  
  29. else{ //if the cookie does not exist, they are taken to the login screen
  30. header("Location: login.php");
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement