Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Connects to your Database
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbname = 'e-hcls';
- $con = mysql_connect($dbhost, $dbuser) or die('Could not connect: ' . mysql_error());
- mysql_select_db($dbname) or die(mysql_error());
- //checks cookies to make sure they are logged in
- if(isset($_COOKIE['ID_my_site']))
- {
- $userid = $_COOKIE['ID_my_site'];
- $pass = $_COOKIE['Key_my_site'];
- $check = mysql_query("SELECT * FROM user WHERE user_id = '$userid'")or die(mysql_error());
- while($info = mysql_fetch_array( $check ))
- {
- //if the cookie has the wrong password, they are taken to the login page
- if ($pass != $info['user_pass'])
- {
- echo "KAWASAN LARANGAN: Cookies anda mempunyai katalaluan yang salah. Sila ke <a href='login.php'>Log Masuk</a> untuk masuk semula ke dalam sistem.";
- //header("Location: login.php");
- }
- //otherwise they are shown the admin area
- else
- {
- ?>
- <!-- HTML here -->
- <?php
- }
- }
- }
- else
- //if the cookie does not exist, they are taken to the login screen
- {
- 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>. ";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement