所以我需要弄清楚如何让我的 else 语句返回到我之前的函数 passprotect.html (我开始的文件)。所以我写下我的密码并点击提交。当我点击提交时,它会检查我的 PHP 密码是否正确。如果密码正确,它会写下“你做到了!”。如果它是错误的,我希望它返回到 passprotect.html 站点,并显示一条错误消息,“密码错误,再试一次!”。
这是我的两个代码:
<html>
<body>
<title>FriedBitz</title>
<form action="secret.php" method="post">
Password: <input type=password name=pass></input>
<input type=submit value=Enter>
</form>
</body>
</html>
和
<html>
<body>
HERE IS YOUR RESULT
<?php
if ( $_POST['pass'] === 'test')
{
echo "You did it!";
}
else
{
header('Location:www.example.com');
}
?>
</body>
</html>