Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old May 30th, 2007, 08:37 AM   #1
New Member
 

Join Date: May 2007
Location: bahrain
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 kool77 is on a distinguished road
Red face Echo and Sessions

Hi I have a code of sessions I want to write "Welcome .$_SESSION['user_name']." to the site "after the user login. but I need the user name and the welcome message to be bold and have a color too, I don't know how to do that in php .. because the code is on the left top corner it is a session. ((it is not in the HTML tags))

I know this only
Code:
<?
session_start();
 
if( isset($_SESSION['user_name']) ){
 
ECHO " Main Menu ";
 
ECHO " Welcome ".$_SESSION['user_name']." to the site";
}
?>
I can't change the style or whatever!

Thanks
kool77 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 30th, 2007, 09:17 AM   #2
Elite Veteran
 

Join Date: Jan 2007
Location: You know where
Age: 32
Posts: 4,607
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 karinne is a name known to all karinne is a name known to all karinne is a name known to all karinne is a name known to all karinne is a name known to all karinne is a name known to all
Re: Echo and Sessions

It has to be in HTML tags! Whatever you're spitting out on the browser has to be in HTML tags.
karinne is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 30th, 2007, 04:13 PM   #3
New Member
 

Join Date: May 2007
Location: bahrain
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 kool77 is on a distinguished road
Re: Echo and Sessions

I don't know how to add html to a php code, should i use "Print" command and then <font color='red'> for example.. before the message?
kool77 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 30th, 2007, 07:01 PM   #4
New Member
 

Join Date: May 2007
Location: United Kindom, London and the South East
Age: 19
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Bradster is on a distinguished road
Re: Echo and Sessions

No, say example on your second echo you wanted it to be red you would write it as this.

Code:
ECHO " <font color='red'>Welcome ".$_SESSION['user_name']." to the site</red>";
Just write in the html code into the echo strings. I think anyway, Im not so good at php myself.
Bradster is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 31st, 2007, 09:01 AM   #5
Elite Veteran
 

Join Date: Jan 2007
Location: You know where
Age: 32
Posts: 4,607
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 karinne is a name known to all karinne is a name known to all karinne is a name known to all karinne is a name known to all karinne is a name known to all karinne is a name known to all
Re: Echo and Sessions

Yeesh ... <font> element is deprecated!

You can just do

Code:
<?
session_start
();
if( isset(
$_SESSION['user_name']) ){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-CA" xml:lang="EN-CA">

<head>
    <title>Some title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
</head>

<body>
<h1>Main Menu</h1>
<h2>Welcome <?=$_SESSION['user_name']?> to the site</h2>
</body>
</html>
<? }?>
karinne is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 31st, 2007, 08:16 PM   #6
Reputable Member
 

Join Date: May 2006
Location: Warrington, UK
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Accurax is on a distinguished road
Re: Echo and Sessions

or you acn echo html tags themselves

eg ;

Code:
echo "<h2>";
echo "Welcome";
echo $_SESSION['foobar'];
echo "To Our site";
echo "</h2>";
you can even add a class or id to the h2 to style it;

Code:
echo "<h2 id=\"welocome\">";
echo "</h2>";

ps;
please keep your php commands in the corect case... echo should be in lower case not capitals

Last edited by Accurax; May 31st, 2007 at 08:21 PM..
Accurax is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old June 1st, 2007, 06:32 PM   #7
New Member
 

Join Date: May 2007
Location: bahrain
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 kool77 is on a distinguished road
Re: Echo and Sessions

oh that's very good I learnt a lot about echo.. I didn't imagine that it does all that work.

Thank you very much all.
kool77 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
echo , question , sessions , simple


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
echo proxy to csv stiassny JavaScript 1 April 13th, 2008 12:51 PM
How do I echo <?php ..... AdRock PHP 12 September 14th, 2007 09:20 AM
Echo and If simonb PHP 2 August 27th, 2007 12:22 PM
how to echo 2 classes geyids PHP 3 August 9th, 2007 09:47 AM
Echo vs Print Sqrlgrl PHP 3 May 30th, 2005 06:31 PM


Search Engine Optimization by vBSEO 3.2.0 RC8