I am working with the page that is redirected to after user authentication.
The page uses the authenticated users e-mail address to query the database, and pull other fields from the users record in as variables.
The session variable is stored correctly, as I can recall it. However, the other variables keep showing up as undefined even though I have defined them in the previous statement. I suspect the problem is here:
while ($row = mysql_fetch_assoc($result))
{
$full_name = $row['full_name'];
$accountname = $row['account'];
$work = $row['work_phone'];
}}
Here is the full code, in case this isn't it.
<?php
session_start( );
?>
<?php
$username_DB = "root";
$password_DB = "Bangladesh09" ;
$host = "Localhost" ;
$TTA_auth = mysql_connect($host, $username_DB, $password_DB)
or die ("unable to connect");
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Log your Support Call</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
width:581px;
height:447px;
z-index:1;
left: 16px;
top: 56px;
}
#apDiv2 {
position:absolute;
width:783px;
height:414px;
z-index:1;
left: 142px;
top: 157px;
}
-->
</style>
</head>
<?php
// Using session variable from the preliminary authentication, we call to database //to get all other information on the recordset
$db_selected = mysql_select_db('tta_support', $TTA_auth);
if (!$db_selected)
{
die ('Can\'t use this Database : ' . mysql_error());
$query = sprintf("SELECT full_name, email, work_phone, account FROM tta_user_auth WHERE email ='".$_SESSION['Username']."'");
// Perform Query
$result = mysql_query($query);
// Check result
// This shows the actual query sent to MySQL, and the error.
if (!$result)
{
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
// Create variables using the results from the query
while ($row = mysql_fetch_assoc($result))
{
$full_name = $row['full_name'];
$accountname = $row['account'];
$work = $row['work_phone'];
}}
?>
<body>
//This is the variable I can't get to work??
<?php print $full_name; ?>
</body>
</html>
I browsed the forum, but couldn't find a similar post. What's going on here?