I am trying to pass value from Login.php page to Dashboard.php. However,it is not displaying any output.
Login.php
//there are no spaces before this
<?php
session_start();
$username= $_POST["txtUsername"]; //it does contain a value
if (empty($_POST["txtUsername"])) {
echo "<script> alert('Please enter username.')</script>";
$url = 'Homepage.php';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
else
{
$query= "Select User_ID, U_Username, U_Password from users where U_Username='$username' and U_Password='$pass'";
$result=mysql_query($query);
$count=mysql_num_rows($result);
$row=mysql_fetch_array($result);
if($count==1) //and count is 1
{
$_SESSION['login_user'] = $row['U_Username'];
$url = 'Dashboard.php';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
}
else
{
echo "<script> alert('Invalid Username or Password.')</script>";
$url = 'Homepage.html';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
}
}
?>
Dashboard.php
<?php
session_start();
echo $_SESSION['login_user'];
?>
//html code after this
When Dashboard.php is displayed it shows the result of the html code only and does not echo the session variable.
Kindly advise..