This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 29th, 2012  |  syntax: PHP  |  size: 0.87 KB  |  views: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3.  // Connects to your Database
  4.  
  5.  mysql_connect("localhost", "root", "") or die(mysql_error());
  6.  
  7.  mysql_select_db("testing") or die(mysql_error());
  8.  
  9.  
  10.  //checks cookies to make sure they are logged in
  11.  
  12.  if(isset($_COOKIE['ID_my_site']))
  13.  
  14.  {
  15.  
  16.         $username = $_COOKIE['ID_my_site'];
  17.  
  18.         $pass = $_COOKIE['Key_my_site'];
  19.  
  20.                 $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
  21.  
  22.         while($info = mysql_fetch_array( $check ))      
  23.  
  24.                 {
  25.  
  26.  
  27.  
  28.  //if the cookie has the wrong password, they are taken to the login page
  29.  
  30.                 if ($pass != $info['password'])
  31.  
  32.                         {                       header("Location: loginscript.php");
  33.  
  34.                         }
  35.  
  36.  
  37.  
  38.  //otherwise they are shown the admin area       
  39.  
  40.  else
  41.  
  42.  
  43.  
  44.  //if the cookie does not exist, they are taken to the login screen
  45.  
  46.  {                       
  47.  
  48.  header("Location: newlogin.php");
  49.  
  50.  }
  51.  
  52.  ?>
clone this paste RAW Paste Data