Jump to content
xisto Community
godlymoose

Welcome <username> Help I need some help

Recommended Posts

I already searched and I couldn't find a topic like this. But if there is I'm sorry. What I need help with is though. I need help having a "Welcome Guest" else "Welcome GodlyMoose". I want to put it on my index page also. I've looked everywhere and I cant find the code for it. I've tried making my own that failed. If I could use some help I would be very happy if someone could help me.

Share this post


Link to post
Share on other sites

When you guys learn to give a full information. Becose answer for you question is:

<?phpif (somthing){  print "Wlecome GodlyMoose";}else{  print "Welcome Guest";}?>

Write for what you need them, meybe wanna change phbb forum or else, mebye you use sql, meby only cookies. How i can know what you wanna do :D


--------------------

Practice is when evrything work but no one know why.
Theory is when work nothing but evry one know why.
Programmers join Practice with Theory - nothing work and no one know why :D

Share this post


Link to post
Share on other sites

I want to know if you can do something like this. I tried using something like this but it does not seem to work.

<?phpif ( $userdata['session_logged_in'] ) { echo "Welcome " . $userdata['username'];} else { echo "Welcome guest, please log in.";}?>

Share this post


Link to post
Share on other sites

It's look like part of bigger project :D (exacly like phpbb :D ) .. you just cut and paste this 6 lines i think.

 

Ok lets start from begining:

 

$userdata (is table variable) and must be declared earlier, like this

 

$userdata['username'] = "Some guy";

$userdata[''session_logged_in'] = true;

 

Above you got this what you missed :D and how you get this data to $userdata tabble variable ... it's depend what you use to collect data. Phpbb use sql + php session, declare this $userdata as session data and use then evry time when open page getting from session.

 

Well if you write this two lines beforu you six lines, you get: Welcome Some guy message.

 

 

--------------------

 

Practice is when evrything work but no one know why.

Theory is when work nothing but evry one know why.

Programmers join Practice with Theory - nothing work and no one know why :D

Share this post


Link to post
Share on other sites

Hmm, doesnt sound too hard o.O

heres my go >.>

//check if there is a user sessionif($userdate['session_logged_in']==true){$log=$userdata['session_logged_in'];$welcome="Welcome back, ";$user=$userdata['username'];}else {$welcome="Please login or register, "";$user="Guest";}//Great the userecho "".$welcome."".$user."";

Tell me if this works..if its not ill dig into PHPbb...

Share this post


Link to post
Share on other sites

Hey, I think just got through the same problem in phpBB (if that's what you're using). I'm guessing about a lot of things regarding your problem, Godlymoose, but I hope this will help.

 

Godlymoose, next time you ask for help, please be more detailed about your problem. For example, in this case, tell us what product you're trying to change the code for, and what results you got from what you tried to do--like any error messages, or weird code, or something. If you got a blank space, tell us that too.

In the latest release of phpBB, the variable {USERNAME} is not defined (I have no idea why). PHP code will not work on template pages, and you must do a song and a dance to integrate separate pages into the phpBB system (see part "C)" of this post).

Please let me know how this works out...

 

== TABLE OF CONTENTS: ==

A) WHAT YOU MUST DO

B) WHAT I THINK WILL DISPLAY EXACTLY WHAT YOU WANT

C) HOW TO PUT THIS ONTO YOUR INDEX PAGE (if it's not part of phpBB)

 

== CONTENTS: ==

*** A) WHAT YOU MUST DO: ***

 

If you want to use {USERNAME} to display the username in a template,

 

1. OPEN includes/page_header.php from the root dir of the phpBB installation.

 

2. FIND the place where there's a long list of variables--it should start like this:

 

$template->assign_vars(array(	'SITENAME' => $board_config['sitename'],	'SITE_DESCRIPTION' => $board_config['site_desc'],
3. And somewhere in there, before the array (the list) ends, INSERT this line:

 

	'USERNAME' => $userdata['username'],

*** B) WHAT I THINK WILL DISPLAY EXACTLY WHAT YOU WANT ***

 

AFTER you make the changes in page_header.php, someone who isn't logged in will have the {USERNAME} "Anonymous," not "Guest."

BUT You can go around this if you INSERT the following lines.

 

<!-- BEGIN switch_user_logged_in -->Welcome, {USERNAME}<!-- END switch_user_logged_in --><!-- BEGIN switch_user_logged_out -->Welcome, Guest.<!-- END switch_user_logged_out -->

*** C) HOW TO PUT THIS ONTO YOUR INDEX PAGE ***

If you want to put this text on a page that's not part of your board, you must follow the instructions here: https://www.phpbb.com/kb/article.php?article_id=143

 

And then, wherever you want this text to show up on your index page, enter the code from part "B)".

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.