Page 1 of 1

Member system, after login

Posted: Thu Feb 19, 2004 3:10 pm
by Thuy
Sorry, if this question is really stupid, but I just can't figure it out. Ok, I have a member system, and people can register, login, blah blah blah. But after they login, can I make it so they see some stuff that non-members can't. Not like a protected page where you have to login to view, but they don't see the extra stuff at all.

Say, before you login, the page looks normal, a link to login and what not. Then once you logged in, you can see some other stuff. Like instead of a link to login, but a link to log out. And a section thats there when you logged in, but wasn't there when you weren't logged in. Sorry for my newbie-ness

Not I'm really sure how to explain it, hope its clear enough -_-;;

My friend said this, but I don't understand it >.<
Do z-inclusion. Make the login form the first thing to be z-included. Around, the z-inclusion, put the extra links you wanted to put.

Posted: Thu Feb 19, 2004 5:26 pm
by tim
I have no idea about that but what you want is simple, post your code and we'll tell you what to add to achieve your goal.

Posted: Thu Feb 19, 2004 5:38 pm
by 1veedo
if statements come in handy... :lol:, I wasn't being sarcastic but it sounds simple. How are they loged in, is there a variable with ther'e s/n? So if (sn != unregerestered){do this} else {do this}. Put that wherever you want the change to be.

Posted: Fri Feb 20, 2004 2:49 pm
by Thuy
Would this work?

if ($username != unregistered){<? include('header1.txt'); ?>} else {<? include('header_in.txt'); ?>}

Posted: Fri Feb 20, 2004 3:22 pm
by vigge89
nope becuase you can't use a php-tag inside a php tag, something like this will work:

Code: Select all

<?php

if ($loggedin != true) { //not logged in

include ('header1.txt');

} else { // logged in

include ('headead_in.txt');

}

?>

Posted: Fri Feb 20, 2004 4:03 pm
by John Cartwright

Code: Select all

<?
displayhidden=0;

if ($loggedin == true) {
$displayhidden=1;
} ?>
Then lets say on a part where you want to display a login link(if not logged in) or a logout link (if you are logged in) you would put this:

Code: Select all

<?php
if ($diplayhidden=1){

echo "<a href="user.php?p=login">login</a> \n"; // the link to wherever you need to go to, to logout 

}elseif($diplayhidden==0){

echo "<a href="user.php?p=logout">logout</a> \n"; // the link to wherever you need to go to, to logout 



?>
The reason I used the variable $displayhidden is because you can use this variable through hte pages and display specific things at each part of the site instead of a whole page itself. You can also add some more values such as $displayhidden==2 for a purpose of admins that are able to actually edit the site. All depends how simple you want to keep things though.