So, when I run this code on xampp, it works and I can see the variables, without the header.
<html>
<head>
</head>
<body>
<?php
$user="";
$server="";
$db="";
$pass="";
$con=mysqli_connect($server,$user,$pass,$db);
$id=$_POST['loginid'];
$password=md5($_POST['password']);
$result=mysqli_query($con,"SELECT * FROM passwords WHERE userid='$id' AND password='$password'");
session_start();
if($row=mysqli_fetch_array($result)){
require('../connect/registerdb.php');
$rresult=mysqli_query($rcon,"SELECT * FROM registration WHERE userid='$id'");
while($rrow=mysqli_fetch_array($rresult)){
$_SESSION['name']=$rrow['name'];
$_SESSION['dob']=$rrow['dob'];
$_SESSION['userid']=$rrow['userid'];
$_SESSION['sex']=$rrow['sex'];
$_SESSION['family']=$rrow['family'];
$_SESSION['describe']=$rrow['describe'];
$_SESSION['pic']=$rrow['pic'];
$_SESSION['visibility']=$rrow['visibility'];
$_SESSION['registeredon']=$rrow['registeredon'];
$_SESSION['lastlogin']=$rrow['lastlogin'];
require('../connect/emaildb.php');
$eresult=mysqli_query($econ,"SELECT email FROM emaillist WHERE userid='$id'");
while($erow=mysqli_fetch_array($eresult)){
$_SESSION['email']=$erow['email'];
}
}
header('Location:../mainpage.php');
}
?>
</body>
</html>
When I add the header, I get:
Notice: Undefined index: loginid in C:\xampp\htdocs\website\session\session.php on line 12
Notice: Undefined index: password in C:\xampp\htdocs\website\session\session.php on line 13
Why does it work without the header but not with the header?