I'm trying to display the data of the user who logged in from the database but it does not work. I also tried to look answer here in the stack to errors I faced but none of them helped since I can't relate to their Q&As and their questions are different.
So back to my problem, I am getting an error on how to display the data from the database.
Here is the PHP code
<?php
require('db.inc.php');
if(!isset($_SESSION['email'])){
header('Location: home.php');
}
if(isset($_POST['index.php'])){
$data = mysqli_query("SELECT * FROM tbl_account WHERE email = '$email'");
if(mysqli_num_rows($data) > 0){
$fetch = mysqli_fetch_assoc($data);
}
}
?>
Next, here is the form where I want to display the data.
<h1 class="text-primary">Your Information</h1>
<br>
<h5>First Name</h5>
<h3><?php echo $_fetch['firstName'];?></h3><br>
<h5>Last Name</h5>
<h3><?php echo $_fetch['lastName'];?></h3><br>
<h5>Sex</h5>
<h3><?php echo $_fetch['sex'];?></h3><br>
<h5>Email Address</h5>
<h3><?php echo $_fetch['email'];?></h3><br>
</div>
May I request not to close my question? so I can get more insights and answers. I put the error in the comments.