Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- / * here are the session.php variables...
- private $signed_in = false;
- public $user_id;
- public $count;
- public $message;
- public $first_name;
- public $username;
- public $password;
- */
- //************the login function in session.php*********//
- public function login($user) {
- // we have a user
- if($user) {
- $this->first_name = $_SESSION['first_name'] = $user->first_name;
- $this->username = $_SESSION['username'] = $user->username;
- $this->user_id = $_SESSION['user_id'] = $user->id;
- $this->signed_in = true;
- }
- }
- //********************* the test.php page*******************//
- <?php include("includes/init.php"); ?>
- <?php if(!$session->is_signed_in()) {redirect("login.php");} ?>
- <?php
- if(isset($_POST['submit'])){
- echo "first name is ". $_SESSION['first_name']."<br>";
- echo "Username is ". $_SESSION['username']."<br>";
- echo "User id is ".$_SESSION['user_id']."<br>";
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- </head>
- <body>
- <form action="" method='post'>
- <input name='user' type="text">
- <input name='submit' type="submit">
- </form>
- </body>
- </html>
- //******************* the return******************//
- Notice: Undefined index: first_name in C:\xampp\htdocs\gallery\admin\test.php on line 13
- first name is
- Username is william
- User id is 190
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement