私は3つのphpファイルを持っています:最初のlogin-form.php
<?php
if(isset($_POST['user']) && isset($_POST['password']))
{
if(!empty($_POST['user']) && !empty($_POST['password']))
{
$user=$_POST['user'];
$password=$_POST['password'];
header('location:index-test.php');
}
}
?>
<form action='index-test.php' method='post'>
Username <input type='text' name='user'/><br>
Password <input type='text' name='password'/><br>
<input type='submit' name='submit' value='submit'/>
</form>
2番目のindex-test.php
<?php
require 'core-test.php';
if(loggedin())
{
echo 'ok';
}
else
{
include 'login-form.php';
}
?>
3番目のcore-test.php
<?php
function loggedin()
{
if(isset($user) && isset($password))
{
return true;
}
else
{
return false;
}
}
?>
index.php と入力すると、まだデータを入力していないため、login-from.php が出力されます。どこが間違っていますか?