I have some code on a login.php page. It is below: Keep in mind session_start() is at the top of the script page.
If ($rows > 0)
{
//start session and put CID in session variable
$_SESSION['scid'] = $cid;
//get users name
$name = sprintf("SELECT firstn, lastn FROM userinfo WHERE cid='%s'",
mysql_real_escape_string($cid, $con));
$_SESSION['sname'] = $name;
//get admin status
$admin = sprintf("SELECT admin FROM status WHERE cid='%s'",
mysql_real_escape_string($cid, $con));
$_SESSION['sadmin'] = $admin;
//get visiting controller status
$vc = sprintf("SELECT vc from status where cid='%s'",
mysql_real_escape_string($cid, $con));
$_SESSION['svc'] = $vc;
mysql_close($con);
echo("<p> Login Successful! Click <a href = 'index.php'> Here </a> to go back to the main page </p>");
}
else {
echo("<p> Login Unsucessful! </p>"); }
Then on the index.php page. It says:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<center>
<?php
if (!isset($_SESSION['sname']))
{
echo("Welcome " . $_SESSION['sname'] . $_SESSION['scid']);
}
?>
<a href="newatc.html"> New ATC click here! </a><br />
<A href="roster.php"> ATC Roster </A> <br />
<A href="login.html"> Click here to login </A>
</center>
</body>
</html>
I'm trying to get the users name and CID to display. It dosen't. On the index.php page it dosen't display anything except the links. Any tips?