Advertisement
Guest User

Untitled

a guest
Jun 16th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2. // Starting the session
  3. session_start();
  4.  
  5. if(isset($_SESSION['user']))
  6.     {
  7.         // Code for Logged members
  8.  
  9.         // Identifying the user
  10.         $user = $_SESSION['user'];
  11.        
  12.         // Information for the user.
  13.        
  14.         echo "hello user!";
  15.     }
  16. else
  17.     {
  18.         echo "hello guest";
  19.    
  20.     }
  21. ?>
  22.  
  23.  
  24. <?php
  25.  
  26. //Code for Logging a User:
  27.  
  28. //Username Stored for logging
  29. define("USER", "user");
  30.  
  31. // Password Stored
  32. define("PASS", "123456");
  33.  
  34. // Normal user section - Not logged ------
  35.         if(isset($_REQUEST['username']) && isset($_REQUEST['password']))
  36.             {
  37.                 // Section for logging process -----------
  38.                 $user = trim($_REQUEST['username']);
  39.                 $pass = trim($_REQUEST['password']);
  40.                 if($user == USER && $pass == PASS)
  41.                     {
  42.                         // Successful login ------------------
  43.                        
  44.                         // Setting Session
  45.                         $_SESSION['user'] = USER;
  46.                        
  47.                         // Redirecting to the logged page.
  48.                         header("Location: index2.php");
  49.                     }
  50.                 else
  51.                     {
  52.                         echo "sorry wrong username and password";
  53.                        
  54.                     }
  55.                
  56.             }
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement