Member system, after login

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Thuy
Forum Newbie
Posts: 2
Joined: Thu Feb 19, 2004 3:10 pm

Member system, after login

Post 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.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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.
1veedo
Forum Commoner
Posts: 31
Joined: Thu Feb 19, 2004 3:59 pm
Location: With my computer wherever that may be.
Contact:

Post 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.
Thuy
Forum Newbie
Posts: 2
Joined: Thu Feb 19, 2004 3:10 pm

Post by Thuy »

Would this work?

if ($username != unregistered){<? include('header1.txt'); ?>} else {<? include('header_in.txt'); ?>}
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post 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');

}

?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
Post Reply