Jump to content

Recommended Posts

I had my own way of doing this until I started worjing with a friend.He gave me a pice of code to use and I have no idead how to get it to work (he is way more advanced than me) here is the code I cant figure out what to do with it.

<?php
		function logged_in(){
		if (isset ($_SESSION['username'])){
		$_SESSION['username'] == true;
		}
		}
			if(logged_in()) {
				echo "<div id=\"navi\">";include "content/website/header.php";"</div>";
        		echo "<div id=\"content\">";include "layout/game.php";"</div>";
        		echo "<div style=\"clear:both;\"></div>";
        		echo "<div id=\"footer\">";include "content/website/footer.php";"</div>";
			} else {
				echo "<div id=\"navi\">"; include "content/website/main_header.php";  "</div>";
        		echo "<div id=\"content\">"; include "layout/content.php";  "</div>";
        		echo "<div style=\"clear:both;\"></div>";
        		echo "<div id=\"footer\">"; include "content/website/main_footer.php"; "</div>";
			}
		?>

Anywy I basicaly have the main website where the else clause is and the site for my game in the logged in pard . What to do??

Link to comment
https://forums.phpfreaks.com/topic/278150-how-do-i-use-this/
Share on other sites

Your logged_in() function does nothing. So your else part will always execute. I also believe you don't want to compare your username to true unless you want to make sure it's not empty or something.

 

function logged_in() {
  return !empty($_SESSION['username']);
}
Link to comment
https://forums.phpfreaks.com/topic/278150-how-do-i-use-this/#findComment-1430935
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.