Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help registering session variables then echo

    FIXED THE SESSION VARIABLES. NOW,

    I am trying to figure out how to echo an html p element with the $_SESSION variable within the paragraph element

    here's my code so far:
    Code:
    <?php
    		if (!isset ($_SESSION['username']))
    		{
    			echo "<a id='reglink' href='register.html' alt='Register'>Register</a>
    			<a id='loginlink' href='login.html' alt='Login'>Login</a>";
    		}
    		else
    		{
    			echo 'Welcome' . 'back' . ' ' . $_SESSION['username'] . '!';
    		}
    		?>
    this is will echo the sentence with the correct username, however, i do not have my css style attached to it..
    any help is much appreciated!
    Last edited by jhdavey; 12-30-2012 at 06:45 AM.

  • #2
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    919
    Thanks
    76
    Thanked 29 Times in 29 Posts
    This will work, checked in Firebug showing the text within a <p>.

    Code:
    echo '<p>Welcome back ' . $_SESSION['username'] . '!</p>';
    Or, you can define the <p> to have a class, then just style it in your CSS file:
    Code:
    echo "<p class='message'>Welcome back ".$user."!</p>";
    
    //then in your CSS file do this:
    
    .message
    {
    //your styles
    }
    Regards,

    LC.
    Last edited by LearningCoder; 12-30-2012 at 11:24 AM.

  • Users who have thanked LearningCoder for this post:

    jhdavey (12-30-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •