Skip to content
WJunction - Webmaster Forum

Quick PHP help...

Status
Not open for further replies.

Jayar

Experienced Member
629
2009
15
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.

About the author

J
Experienced Member · Joined
Life sucks. Then you die. web design, movies, friends, music.
629
Messages
15
Reactions
18
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom