有沒有像unset $msg
或東西,任何解決辦法,當我重新加載頁面時,$味精停止?登錄表單PHP沒有數據庫 - 重裝
這裏是我的代碼:
的index.php:
<form class="ligar" action="log.php" method="post">
<p class="lig"><input name="username" type="text" placeholder="Username"></p>
<p class="lig"><input name="password" type="password" placeholder="Password"></p>
<p class="lig"><input name="Entrar" type="submit" value="log"></p>
<p class="error"><?php if(isset($_GET['msg']))
echo $_GET['msg'];
?>
</p>
</form>
log.php:
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if ($username =='john' AND $password=='abc') {
header("Location:/detalhes.php");
} elseif ($username!='john' OR $password!='abc'){
$msg = "Wrong, try again.";
header("Location:http://localhost/index.php?msg=$msg");
}
?>
你'index.html'包含PHP,所以除非你指示的Apache將無法工作將'.html'視爲PHP。如果沒有,然後重命名爲'index.php' –
是的,我知道,這不是問題。在爲你們編寫代碼時,這是我的一個錯誤。 – dyzz1337
好的。現在,我不太明白你的意思*「當我重新加載頁面時,$ msg停止」*,你能詳細說明一下嗎? –