I have a <div>
inside my onlinestore.html file which is my menu that contain of Login/Register. What I want is after the success login, the <div>
for login/register change to the username. What i'hv done wont display the expected output that i want.So is there something wrong about my code?
Here is what I've done:
onlinestore.html
<li class='active' style='float:right;'>
<?php
session_start();
if($_SESSION['logged']==true){
echo $_SESSION["username"];
echo '<a href="logout.php"><span>Logout</span></a></li>';
}
elseif($_SESSION['logged']==false)
echo '<a href="registerform.html"><span>Login/Register</span></a></li>';
?>
Here is another file checklogin.php:
if($count==1){
session_start();
$_SESSION['logged']=true;
$_SESSION ['username']=$myusername;
header("refresh:1;url=onlinestore.html");
}
else{
$_SESSION['logged']=false;
header("refresh:2;url=login.html");}
Here is the expected output:
Before Login
After Login
Here is what i get with the code above: