Jump to content


PHP Forum


2 replies to this topic

#1 jakevfr

    Young Padawan

  • Members
  • Pip
  • 40 posts

Posted 10 May 2006 - 03:28 PM

I want to make a forum. So I have used this tutorial tutorial And I want to make it so if you log in the name is your username (defined by session) and if not your name is guest. I've tried to put an if then statement (not sure if that is what that is called in PHP, but that is what it's called in BASIC :D) but it doesn't work. I have little experience with PHP so that is probably my problem... Could someone help.

And I know I can download something that will make them but I would like to make my own.

#2 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 10 May 2006 - 03:45 PM

you shouldn't be trying to make a forum if your a beginner.

but this is what i do on my forums (im also creating em).

have the login form (duh?) then when the user logs in, check if passwords/username match (duh again). if they match, use

$_SESSION['username'] = $username_var;


of course, you need to have session_start() at the top of every page.

if the user is not logged in, don't define a session, instead, wherever you need to get a name, use:
if(!isset($_SESSION['username']))
{
   $username = "Guest";
}
else
{
   $username = $_SESSION['username'];
}

make sense?

#3 jakevfr

    Young Padawan

  • Members
  • Pip
  • 40 posts

Posted 10 May 2006 - 04:31 PM

Yeah

and don't worry I'm not that simple. I've been working with PHP for maybe a month now. But thanks for your help :D

Edited by jakevfr, 10 May 2006 - 04:55 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users