If statment to say if the user is logged in or not.
Posted: Wed Jun 29, 2011 3:38 pm
Hello,
On the user login system i want the user to be able to login from the index.php page. I have set that up but i am having some problems with getting it to change when the user is logged in. I want it so when the user is not logged in the login form shows and when the user is logged in i want a menu with all user settings to show. This is the code i have tried and it didn't work.
On the user login system i want the user to be able to login from the index.php page. I have set that up but i am having some problems with getting it to change when the user is logged in. I want it so when the user is not logged in the login form shows and when the user is logged in i want a menu with all user settings to show. This is the code i have tried and it didn't work.
<?php if ($_SESSION['username']) { echo "You are logged in"; } else {?> <form action="login.php" method="POST"> <p> <label for="username">Username:</label> <input type="text" name="username" id="username" value="<?php if (isset($_POST['username'])) echo htmlentities($_POST['username']); ?>" /> </p> <p> <label for="password">Password:</label> <input type="password" name="password" id="password" /> </p> <p> <input type="submit" name="submit" value="Login" /> </p> </form> <?php } ?>Can someone tell me what i have done wrong here.