I'm doing a sort of login page for my website which I'm just testing right now, and this code is after the login. The thing is, I want to retrieve some information from my database, but the code doesn't work (it doesn't echo anything). I checked that the MySQL query is fine and it works, but there is no result in the PHP.
Please I would be happy for any help and answers,
//---MySQL connection---//
$server = "localhost";
$user = "root";
$pass = "password";
$db = "users";
$table = "users";
mysql_connect($server,$user,$pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
//----------------------//
//---MySQL query, data selection---//
$sesuser = $_SESSION['username'];
$sql = "SELECT data FROM $table WHERE username='$sesuser'";
$predata = mysql_query($sql);
$data = mysql_fetch_field($predata);
//---------------------------------//
//---Check if session is registered---//
session_start();
if(session_is_registered("username")){
echo "\n"."Hello ".$_SESSION["username"]."<br />";
echo $data; //!!this line doesn't work
}
else{
echo "<script>window.location=/login/</script>";
}
//------------------------------------//
?>