SHARE
TWEET

Untitled

a guest Mar 29th, 2012 19 Never
  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.  ?>
RAW Paste Data
Top