Jump to content

[SOLVED] Members Only


stuart7398

Recommended Posts

hi.

i have a members only section where users register and login to view their profile

 

How do i get their links such as 'my profile' 'my messages' to show only when logged in, then to disapear when logged out?

 

would i have to create a new navigation bar and switch between the 2?

 

thanks,

stuart.

Link to comment
https://forums.phpfreaks.com/topic/100121-solved-members-only/
Share on other sites

hi.

i have a members only section where users register and login to view their profile

 

How do i get their links such as 'my profile' 'my messages' to show only when logged in, then to disapear when logged out?

 

would i have to create a new navigation bar and switch between the 2?

 

thanks,

stuart.

 

 

what would i do to this session to acheive my goal?

 

 

<?php

require_once('auth.php');

?>

<?php $page_title = 'Member Index'; @ require_once ('../inc/head.php'); ?>

<link href="loginmodule.css" rel="stylesheet" type="text/css" />

<h1>Welcome to Members' area!</h1>

<a href="members/member-profile.php">My Profile</a> | <a href="members/logout.php">Logout</a>

<p>This is a password protected area only accessible to members. </p>

</div></div>

<?php

@ require_once ('../inc/leftnav.php');

@ require_once ('../inc/rightnav.php');

@ require_once ('../inc/foot.php');

?>

 

 

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/100121-solved-members-only/#findComment-511901
Share on other sites

 

On login page you have to register some session

$_SESSION['uid']=$userid;

<?php
   require_once('auth.php');
   if(!$_SESSION['uid']) {
    header("Location: login.php"); //if not logged in dont allow to view th page 
    exit();
   }
?>
<?php $page_title = 'Member Index'; @ require_once ('../inc/head.php'); ?>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<h1>Welcome to Members' area!</h1>
<?php if($_SESSION['uid']) {  ?>
<a href="members/member-profile.php">My Profile[/url] | <a href="members/logout.php">Logout[/url]
<?php } ?>
<p>This is a password protected area only accessible to members. </p>
</div></div>
<?php
@ require_once ('../inc/leftnav.php');
@ require_once ('../inc/rightnav.php');
@ require_once ('../inc/foot.php');
?>

  ;) ;) ;)

Link to comment
https://forums.phpfreaks.com/topic/100121-solved-members-only/#findComment-511906
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.