I have 2 sessions that store first name and last name from the MySQL database. I want to display the first name and last combined on the dashboard page when the user logs in. Please assist.
Below is the code that checks login.
if(isset($_POST['login']))
{
if(!empty($_POST['email']) && !empty($_POST['password']))
{
$email = trim($_POST['email']);
$password = trim($_POST['password']);
$md5Password = md5($password);
$sql = "SELECT * from tbl_users where email = '".$email."' and password = '".$md5Password."'";
$rs = mysqli_query($conn,$sql);
$getNumRows = mysqli_num_rows($rs);
if($getNumRows == 1)
{
$getUserRow = mysqli_fetch_assoc($rs);
unset($getUserRow['password']);
$_SESSION = $getUserRow;
// $_SESSION['alogin']= $_POST['email'];
$_SESSION['id']=$getUserRow['id'];
$_SESSION['first_name']=$getUserRow['first_name'];
$_SESSION['last_name']=$getUserRow['last_name'];
header('location:dashboard.php');
exit;
}
else
{
$errorMsg = "Wrong email or password";
}
}
}
Dashboard code:
<p>
You are logged in as
<?php echo $_SESSION['first_name']?>
<!-- Alexander Pierce - Web Developer -->
<small>Member since Nov. 2012</small>
</p>