When I go to the index page directly, it direct me to the login page. And when I enter the email and password and submit that, it stays on the login page.
I think the problem is in the session between the config file and the index page.
Here is the config: (please don't focus to mysql, i still want to use it)
<?php
ob_start();
error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors", true);
error_reporting(-1);
ini_set('display_errors', 'On');
mysql_connect("","","") or die("cannot connect");
mysql_select_db("") or die("Gagal");
$myemail= $_POST['myemail'];
$mypassword= $_POST['mypassword'];
$sql= "SELECT * FROM user WHERE myemail='".$myemail."' and mypassword='".$mypassword."'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1)
{
echo "Login successful";
session_register("myemail");
session_register("mypassword");
header("location:index.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
Then in the index page I have this session in the header:
<?php
session_start();
if(!session_is_resgitered(myemail)){
header("location:login.html);
}
?>
Please help me to clear this one, I have tried so many ways just to achieve this login function. Thank you.