php - "echo" session and logout in the same line

448

Currently when i showing my username(through session) and logout function , both of them is in different lines

Image: http://prntscr.com/nc2v1b ( This is output )

What i want : https://prnt.sc/nc2w23
Username is on the right side of "Logout"

957

Answer

Solution:

First of all, remove this partstyle='float:right;'

Usingfloat:right will move the text right.

Second, need some spacing here:

echo $_SESSION["username"]." "; // you can use `|` to separation 
echo '<a href="logout.php"><span>Logout</span></a></li>';
487

Answer

Solution:

Float right will push everything to the right (last item being the one the the most on the right). Your code seem to work if you need to have everything on one line though.

<?php
session_start(); // Right at the top of your script
?>

<li class='active'>
 <?php 
 if($_SESSION['logged']==true)
 { 
     echo '<a href="logout.php"><span>Logout</span></a>' . $_SESSION["username"];
 }
 else
 {
     echo '<a href="registerform.html"><span>Login/Register</span></a>';
 }

 echo '</li>';
?>

People are also looking for solutions to the problem: php - Prestashop 1.6 Amount Tampering While Check Out

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.