0

How do i put div tag in my example echo here?

 if ($_SESSION['username'])
 {
 echo "you are logged in as: ".$_SESSION['username'];
 }

I want to put style(css)on that $_SESSION(username) whoever logins. For example, you are logged in as: Sam
I want to style the name Sam.

Edited by pritaeas: Moved.

2
Contributors
7
Replies
9
Views
5 Years
Discussion Span
Last Post by Eggstraordinary
0

If you only want to adjust the name, I suggest:

echo 'you are logged in as: <span id="username">' . $_SESSION['username'] . '</span>';

then you can style using span#username. There are many more options of course.

0

i tried your code and got an error Unexpected T_STRING. I tried rearranging quotation marks if thats the problem but still displaying an error. What are the other option you know?

0

This is my code:

<?php

session_start();

if ($_SESSION['username'])
{
 echo "You are logged in as: " .$_SESSION['username'];
 echo "<p>";
 echo "<a href='logout.php'>Log out</a>";
}
else
    header("location: index.php");
?>

As you can see, there's no div or span tag as i can't figure it out on how/where to put it as it display an error.

0

What I meant was, show the code that gave the error (and the error message). You must have missed a quote.

1

Dude! It's working! I tried again your code and it works. I don't know but i did the same thing awhile ago.. I think i don't need now to post the code? Thank you so much!! :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.