Web Hosting Talk







View Full Version : help session variable not working!


tttt
05-21-2008, 03:04 PM
I am trying to load a session variable with a username and then, using an if statment display it if the condition is true the if atatement works but the session variable wont display the name. whats the problem?
here is my code:

<?php
session_start();
$_SESSION['name']=$name;
$username = $_POST[("userId")];
$password = $_POST[("Password")];

$dbc = mysql_connect...
$queryItem = "SELECT ...

if (empty($row)) //form validation
{
header("Location: logon.php");
}
else
{
$name = $row['user_name']; //place username into session id
echo $_SESSION['name']; //it doesnt display the name
}
?>

Steve_Arm
05-21-2008, 03:08 PM
You start with
session_start();
$_SESSION['name']=$name;

Where exactly $name is been filled before the start of the script (<?) ?

tttt
05-21-2008, 03:21 PM
ok I got it I've put the $SESSION some place else in the code and $name above it.
Thanks