I'm new to PHP and am even more of a beginner when it comes to sessions. I have my index.php page, which is where users can register and login. The forms are posting to submit.php, respectively for registering and logging in.
This is the dashboard.php file where i showed the username of a user and email address from which account he's login.
<?php
session_start();
include "includes/config.php";
include "layouts/header.php";
$s_title = "Superior Results";
if(isset($_SESSION['id'])) {
$username = $_SESSION['username'];
$email = $_SESSION['email'];
$id = $_SESSION['id'];
} else {
header('Location: index.php');
die();
}
$sql = "SELECT email, username FROM members";
$result = mysqli_query($dbCon, $sql);
$row = mysqli_fetch_assoc($result);
?>
And this is how i call these session variables in dashboard.php file
<?php echo $_SESSION['username'];?>
<?php echo $_SESSION['email'];?>
Username works but email didn't work it shows Notice: Undefined index: email
$_SESSIONvariables? I'm missing something like$_SESSION['email'] = $row['email'].spuit elf. No worries, a translation will not help you.