I'm trying to display a users email on an index page after they've successfully logged in here's the login code
<?php
include("config.php");
if($_REQUEST['sub']){
$id=$_REQUEST['t1'];
$pass=$_REQUEST['p1'];
$sel=mysql_query("select customer_email,customer_password, customer_fname from customers where customer_email='$id'");
$arr=mysql_fetch_array($sel);
if(($arr['customer_email']==$id) and( $arr['customer_password']==$pass))
{
session_start();
$_SESSION['loggedin'] = true;
$_SESSION['customer_email '] = $id ;
echo "<script>location.href='index.php'</script>";
}else{
$er="Invalid email or password";
}
}
?>
t1 is the textbox where the user enters their email and p1 is the passwod textbox where the user enters their password and sub in the id of the login button. Here's the code for displaying the email in the index page
<?php
error_reporting(1);
session_start();
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
$us= "Welcome , " . $_SESSION['customer_email'] . "!";
} else {
$us= "Welcome guest.";
}
?>
I want it to be displayed next to the websites navigation links. So here the code that puts $us next to them
<div id="Top_menu">
<a class="kart" href="index.php?con=15"><span>CART</span></a>
<a class="contact" href="index.php?con=1"><span>CONTACT</span></a>
<a class="aboutus" href="index.php?con=2"><span>ABOUT US</span></a>
<a class="home" href="?page=home"><span>HOME</span></a>
<?php echo "<font color='green'>$us</font>";?>
Whenever I run the code it displays hello guest fine when the user isn't logged in but when a user is logged in it only displays Welcome,!