有没有像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停止”*,你能详细说明一下吗? –