i am using session variable to send details of user from login page to welcome page .
here is my code :
<?php
if(isset($_POST['login']))
{
$email=$_POST['email'];
$pass=md5($_POST['password']);
$a="SELECT * FROM users WHERE email='$email'AND password='$pass'";
$log=mysqli_query($con,$a);
$row=mysqli_fetch_array($log);
if(mysqli_num_rows($log)>0){
$_SESSION['firstname']=$row['first_name'];
$_SESSION['lastname']=$row['last_name'];
header("location:welcome.php");
exit;
}
else{
$er="login failed!";
}
}
on Welcome.php
<h2>WELCOME : <?php echo $_SESSION['firstname'];?></h2> <--- line 63-->
but i am getting this error :
Notice: Undefined index: firstname in C:\xampp\htdocs\website\welcome.php on line 63
PS : kindly dont mark it as duplicate I tried many solutions but not helping. I used session_start(); on every page .