How to keep the Log-In Form from reappearing

I’m using the PHPmotion script:
and I’ve succeeded in getting the Log-In Form (on the home page) to disappear, once it successfully performs it’s function, (which is what I’m trying to accomplish), but as soon as the Log-In function succeeds, and the “sub-menu” on the home page appears,
the Log-In Form reappears again.

So, I’m assuming the sub-menu has something to do with the Log-In Form reappearing.

Which looks like this:



Any thoughts/solution about this will be greatly appreciated.

Assuming First part of your code related to log-in form and second part of your code related to sub-menu,
First go to your log-in action form ( I mean go to method or class which has validate username and password and authenticate user. Then after success full login add below code

$_SESSION[‘username’] = $_POST[‘user_name_login’];

This will keep Username in global variable and can use anywhere in system for that particular session.

Then begging of in each of your page


if(!isset($_SESSION[‘username’]) || empty($_SESSION[‘username’])){
header(“Location: log-in.php”); // Use your login page

Important Make sure to unset in your logout action/method
you can do this by using below code




PS I have serious doubt below part of your code

form action=“…/login.php” method=“post”"
Because may be this is the reason your code keep redacting to login page.

And i strongly recommend not to use style in your code keep in in separate CSS file and use.

Hope this will help you.
Happy codding :smile: