Guest User

Untitled

a guest
May 10th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if(!isset($_SESSION["manager"])){
  4.  header("location: admin_login.php");
  5.  exit();
  6. }
  7. //Be sure to check that this manager session value is in the database
  8. $managerID = preg_replace('#[^0-9]#i','',$_SESSION["id"]); //filter everything but numbers and letters
  9. $manager = preg_replace('#[A-Za-z0-9]#i','',$_SESSION["manager"]); //filter everything bu numbers and letters
  10. $password = preg_replace('#[A-Za-z0-9]#i','',$_SESSION["password"]); //filter everything bu numbers and letters
  11. //run sql query to be sure that this person is an admin and that their password session variale equals the database information
  12.  
  13. //Connect to the MySQL database
  14. include "../Scripts/connect_to_mysql.php";
  15. $sql=mysql_query("SELECT * FROM admin WHERE id='$managerID' AND username='$manager' AND password='$password' LIMIT 1"); //query the person
  16. //--------Make sure the Person exists--------
  17. $existCount = mysql_num_rows($sql); //Count the num rows
  18. if($existCount==0){//evaluate the count
  19.     echo "Your login session data is not on record in the database.";
  20.     exit();
  21.  
  22.     header("location:../index.php");
  23.     exit();
  24. }
  25. ?>
  26.  
  27. <?php // Script 3.4 - index.php
  28. $page_title = 'Store Admin Page';
  29. include ('includes/header.php');
  30. ?>
  31.  
  32. <h1>Welcome to the admin area of the online book store.</h1>
  33.  
  34. <p><a href="#"></a>Manage Inventory Items</p>
  35.  
  36. <?php
  37. include ('includes/footer.php');
  38. ?>
Add Comment
Please, Sign In to add comment