Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Starting the session
- session_start();
- if(isset($_SESSION['user']))
- {
- // Code for Logged members
- // Identifying the user
- $user = $_SESSION['user'];
- // Information for the user.
- echo "hello user!";
- }
- else
- {
- echo "hello guest";
- }
- ?>
- <?php
- //Code for Logging a User:
- //Username Stored for logging
- define("USER", "user");
- // Password Stored
- define("PASS", "123456");
- // Normal user section - Not logged ------
- if(isset($_REQUEST['username']) && isset($_REQUEST['password']))
- {
- // Section for logging process -----------
- $user = trim($_REQUEST['username']);
- $pass = trim($_REQUEST['password']);
- if($user == USER && $pass == PASS)
- {
- // Successful login ------------------
- // Setting Session
- $_SESSION['user'] = USER;
- // Redirecting to the logged page.
- header("Location: index2.php");
- }
- else
- {
- echo "sorry wrong username and password";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement