Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <?php
  2. // Connects to your Database
  3. $dbhost = 'localhost';
  4. $dbuser = 'root';
  5. $dbname = 'e-hcls';
  6. $con = mysql_connect($dbhost, $dbuser) or die('Could not connect: ' . mysql_error());
  7. mysql_select_db($dbname) or die(mysql_error());
  8.  
  9. //checks cookies to make sure they are logged in
  10. if(isset($_COOKIE['ID_my_site']))
  11. {
  12. $userid = $_COOKIE['ID_my_site'];
  13. $pass = $_COOKIE['Key_my_site'];
  14. $check = mysql_query("SELECT * FROM user WHERE user_id = '$userid'")or die(mysql_error());
  15. while($info = mysql_fetch_array( $check ))
  16. {
  17.  
  18. //if the cookie has the wrong password, they are taken to the login page
  19. if ($pass != $info['user_pass'])
  20. {
  21.  
  22. echo "KAWASAN LARANGAN: Cookies anda mempunyai katalaluan yang salah. Sila ke <a href='login.php'>Log Masuk</a> untuk masuk semula ke dalam sistem.";
  23. //header("Location: login.php");
  24. }
  25.  
  26. //otherwise they are shown the admin area
  27. else
  28. {
  29. ?>
  30. <!-- HTML here -->
  31.  
  32. <?php
  33. }
  34. }
  35. }
  36. else
  37. //if the cookie does not exist, they are taken to the login screen
  38. {
  39. echo "KAWASAN LARANGAN: <br>1. Cookies tidak wujud. Pastikan browser anda membenarkan penggunaan cookies. Sila hubungi pegawai anda untuk maklumat lanjut. <br>2. Anda tidak login dengan cara yang betul. Sila ke <a href='login.php'>Log Masuk</a>. ";
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement