Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change ENTIRE site if logged in using PHP

I'm creating a website for learning purposes only. I have made it so in the index.php is a basic login form. It is setup with MySQL. I want to make it so when you are not logged in you see the form website in index.php, and when you are logged in you see an entire different site in index.php as well. I know how to check if i am logged in or not, so the basic question is: can i do something like this type of style:

  if(loggedIn){
    include 'loggedInSite.php';
  }else{
    include 'notLoggedInSite.php';
  }

Or does it have to be totally different? Or should I do something along these lines:

  if(loggedIn){
    echo "<html>Whole site</html>";
  }

Echoing out the entire website in a simple echo function?

like image 690
user2246998 Avatar asked Nov 17 '25 17:11

user2246998


1 Answers

Your first example should work just fine with a slight alteration:

if($loggedIn){
  include 'loggedInSite.php';
}else{
  include 'notLoggedInSite.php';
}
like image 85
Tony Avatar answered Nov 19 '25 09:11

Tony



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!