Echo and Sessions

This is a discussion on "Echo and Sessions" within the PHP Forum section. This forum, and the thread "Echo and Sessions are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 30th, 2007, 12:37
Junior Member
Join Date: May 2007
Location: bahrain
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
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: Select all
<?
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
Reply With Quote

  #2 (permalink)  
Old May 30th, 2007, 13:17
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #3 (permalink)  
Old May 30th, 2007, 20:13
Junior Member
Join Date: May 2007
Location: bahrain
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
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?
Reply With Quote
  #4 (permalink)  
Old May 30th, 2007, 23:01
Junior Member
Join Date: May 2007
Location: United Kindom, London and the South East
Age: 17
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Bradster
Re: Echo and Sessions

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

Code: Select all
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.
Reply With Quote
  #5 (permalink)  
Old May 31st, 2007, 13:01
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Echo and Sessions

Yeesh ... <font> element is deprecated!

You can just do

PHP: Select all

<?
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>
<? }?>
Reply With Quote
  #6 (permalink)  
Old Jun 1st, 2007, 00:16
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Echo and Sessions

or you acn echo html tags themselves

eg ;

Code: Select all
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: Select all
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; Jun 1st, 2007 at 00:21.
Reply With Quote
  #7 (permalink)  
Old Jun 1st, 2007, 22:32
Junior Member
Join Date: May 2007
Location: bahrain
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
Reply

Tags
echo, question, sessions, simple

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 Forum 1 Apr 13th, 2008 16:51
How do I echo <?php ..... AdRock PHP Forum 12 Sep 14th, 2007 13:20
Echo and If simonb PHP Forum 2 Aug 27th, 2007 16:22
how to echo 2 classes geyids PHP Forum 3 Aug 9th, 2007 13:47
Echo vs Print Sqrlgrl PHP Forum 3 May 30th, 2005 22:31


All times are GMT. The time now is 18:46.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43