I use Php Sessions to recognize users when they log in with email and password. It works fine. Being new to Php I need to know how to access their ProfileName with Session. The code I use in header.php returns blank, no name.
header.php
<?php
$info = myprofile($_SESSION['memberid']);
$title = $myprofile.' - '.stripslashes($info['ProfileName']);
echo $_SESSION[$title];?>
profile.php
<?php
require_once "../includes/config.php";
if(!$_SESSION['memberid'] || $_SESSION['memberid']==0){
header('Location: '.$base_url.'signin.php');
exit();
}
require_once "../includes/database.php";
require_once "../includes/functions.php";
$info = myprofile($_SESSION['memberid']);
$title = $myprofile.' - '.stripslashes($info['ProfileName']);
require_once '../includes/header.php';
$ismenu = 2;
?>
signin.php
<?php
require_once "includes/config.php";
require_once "includes/database.php";
require_once "includes/functions.php";
if($_SERVER['REQUEST_METHOD']=='POST' && isset($_POST['smsignin'])){
$err = 0;
if(empty($_POST['email'])){
$err_e = $emailnull;
$err = 1;
}
elseif(!valid_email(trim($_POST['email']))){
$err_e = $emailinvalid;
$err = 1;
}
elseif(empty($_POST['password'])){
$err_p = $passnull;
$err = 1;
}
elseif($_SESSION['loginfalse']>=$totallogin){
if(empty($_POST['captcha'])){
$err_c = $captchanull;
$err = 1;
}
elseif(strlen($_POST['captcha'])<6){
$err_c = $datashort;
$err = 1;
}
elseif($_POST['captcha'] != $_SESSION['encoded_captcha']){
$err_c = $captnomatch;
$err = 1;
}
}
if(intval($err)==0){
$data = array(mysql_real_escape_string(trim($_POST['email'])), mysql_real_escape_string(trim($_POST['password'])));
$result = UserLogin($data);
if($result==0)
$error = $errordata;
elseif($result==-1){
$_SESSION['loginfalse'] = isset($_SESSION['loginfalse'])?$_SESSION['loginfalse']+1:1;
$error = $mailpassnotmatch;
}
else{
$banned = chkBannedMe($result);
if(count($banned)>0)
$error = str_replace('<lydo>', $banned[0], str_replace('<ngay>', date('H:i:s d-m-Y', strtotime($banned[1])), str_replace('<link>', '<a href="'.$base_url.'contact.php">', str_replace('</link>', '</a>', $bannedacc))));
else{
$date = date("Y-m-d H:i:s");
updLogon($result);
UpdateVIPStatus($result, $date);
IsVIP($result);
mysql_close();
unset($_SESSION['loginfalse']);
$_SESSION['memberid'] = $result;
$_SESSION['memberemail'] = $_POST['email'];
$direct = $_SESSION['direct']?$_SESSION['direct']:$base_url.'members/myaccount.php';
header('Location: '.$direct);
exit();
}
}
}
}
$title = $memberlogin;
?>