Hi there, I have this problem whereby I am able to retrieve/see the session variable $client_id once the page loads.
However, for other session variables like $client_fname, I would have to refresh the page...THEN the variable shows up.
I dunno why it's like that..pls help
session_start();
session_register("client_id");
session_register("client_fname");
$query = mysql_query("SELECT username, password, client_id FROM account_details WHERE username = '".$_POST['login']."' AND password = '".$_POST['password']."'", $dbconnect);
$num = mysql_num_rows($query);
if ($num > 0) {
$user = mysql_fetch_array($query);
$_SESSION['client_id'] = $user['client_id'];
}
/* Add client_fname, client_lname, client_email to session */
$query_client_info = mysql_query("SELECT client_fname, client_lname, client_email FROM client_info
WHERE client_id = '$client_id'");
$num2 = mysql_num_rows($query_client_info);
if ($num2 > 0) {
$get_client_info = mysql_fetch_array($query_client_info);
$_SESSION['client_fname'] = $get_client_info['client_fname'];
echo ("Welcome " . $get_client_info['client_fname']);
echo ("Client ID " . $user['client_id']);