Welcome <username> Help - I need some help

free web hosting
Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Welcome <username> Help - I need some help

godlymoose
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.

Reply

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

CODE

<?php
if (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 biggrin.gif


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

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 cool.gif

Reply

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

CODE

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


Reply

palladin
It's look like part of bigger project smile.gif (exacly like phpbb wink.gif ) .. 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 smile.gif 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 cool.gif

 

 

 


Reply

squeezer
Maybe .... Hrgggg .. id ont know what to do !!

Reply

cragllo
first off, you should have said you are doing it with phpbb, asuming you are bu looking at teh code you have given... if it is phpbb, say and i can help ^^

Reply

HmmZ
Hmm, doesnt sound too hard o.O

heres my go >.>

CODE

//check if there is a user session
if($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 user
echo "".$welcome."".$user."";


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

Reply

sarephina
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:


CODE

$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:

CODE

'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.


CODE

<!-- 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: http://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)".

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics
Looking for username

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for username

*MORE FROM TRAP17.COM*
advertisement



Welcome <username> Help - I need some help



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE