php trying to echo out username in another php file?

From my logout.php file (below) i want to use the $_SESSION['username']=$myusername; on another php file

what code do i need to use to echo out the users name i have tried

<?php
session_start();
$_SESSION['username'];

if (($_SESSION['auth'] == false)||(!isset($_SESSION['auth']))){
header("location:login.html");
}


echo ($_SESSION['username']);
(also tried echo $username;)
?>



}

but all i get is a blank screen please can someone give some code were i can output the users name

echo ($_SESSION['username']);

?>




<?php

session_start();
$_SESSION['auth']=false;

$host="localhost"; // Host name
$username="20203800"; // Mysql username
$password="ralph"; // Mysql password
$db_name="two0203800"; // Database name
$tbl_name="ralphdb"; // Table name

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form
$myusername=$_POST['username'];
$mypassword=$_POST['password'];

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);


if($count==1){

$_SESSION['username']=$myusername;
$_SESSION['auth'] = true;
$_SESSION['password']=$mypassword;
$path = "location:members.php";
}else {
$path = "location:login.html";
}
header($path);
?>
below is so when logged into web site only members can access

if (($_SESSION['auth'] == false)||(!isset($_SESSION['auth']))){
header("location:login.html");
}
 
Back
Top