I got my user.php, header.php and indexph.php. After i log in, i can show my user data but i want to call it in my header, between every page i explore.. my header is another file on my site, i use "require_once('header.php')" to call it on indexph.php or user.php but when i get out of user.php i lost my username data, here is part of my code..
USER.PHP (not all)
<?php include("conexion.php");
require_once("header.php") ?>
<form action="" method="POST" id="loginform">
   <input type="text" placeholder="Usuario" name="usuar">
   <input type="password" placeholder="Contraseña" name="pw">
   <button type="submit" class="btn" name="logi">Login</button>
   <a href="">Olvidaste la contraseña?</a>
</form>
?>
header.php
<?php
include("conexion.php");
if(isset($_POST['logi'])){
   $u=$_POST["usuar"];
   $c=$_POST["pw"];
   $sql="SELECT * FROM usuario
   WHERE usuario='".$u."' AND contr='".$c."' ";
   $res=mysql_query($sql,$con);
   $can=mysql_num_rows($res);
   $b=mysql_fetch_array($res);
   if($can == 1)
   {
    echo "Login OK by ".$u;
    //echo"".$_SESSION['id_user'];
    //header('location:indexph.php');//te envia luego de logear correctamente
    echo "<form action='logout.php' method='POST'>";
    echo "<button type='submit' name='logo'>Logout</button>";
    echo "</form>";
}
else
{
    echo "Login Failed";
}
}
?>
<header id="header">
<div class="navbar">
<nav>
            <ul id="menuitems">
                <li><a href="../index.html">Home</a></li>
                <li><a href="indexph.php">Productos</a></li>
                <li><a href="añadir.html">Añadir</a></li>
                <li><a href="detalle productos.html">D.P☠</a></li>
                <li><a href="account.html">Cuenta</a></li>
            </ul> 
</nav>
            <a href="kart.php" class="nav-item nav-link active">
            <img src="../img/cart.png" width="50px" height="50px">
            </a>
            <!---here i would like to call my username so it shows in every page that calls 
            header.php---->
</div>
</header>
here is my "indexph.php" one of many pages where i want to show my username just calling header.php
<?php
session_start();
require_once('header.php');
if(isset($_SESSION['usuar']))
{
   echo"<br>Logged by ".$_SESSION['usuar'];
}
?>
<html> <!--- here it would be all html, images and everything---> </html>
But i can't, that "echo" is not working, the thing is want the username on header, thats all plz help i cant solve this :c
 
    