Quick PHP help...

Status
Not open for further replies.

Jayar

Active Member
629
2009
15
40
Hey everyone. I'm coding a simple members area for my website, but i need Alittle help.

Basically I want it to be something like /path/membersindex.php and /path/subpage.php etc.

So on every page i want there to be the code below to check if the person is logged in, and if they're not it shows a logged in screen.

So far I got:

PHP:
<?php
if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username']))
{
	//content here
}
else
{
	//put the login form here
}
<?>

Really what I want help with is if theres a more conventional way to do the above. Like have something like:
PHP:
<?php
require "sessioncheck.php"; //checks  if user is logged in, if they aren't, the page displays a login screen. 

//rest of the page content here

Thanks
 
1 comment
That should work except use require_once and not require. Also make sure to add a return after it displays the login form so it doesn't drop into the code below it.
 
Status
Not open for further replies.
Back
Top