我嘗試編寫可以顯示錯誤消息的登錄過程。在HTML我的登錄表單是這樣的:對於登錄時出現錯誤消息(HTML和php)
<form id="login" action="data/login.php" method="post">
<H2>Rgister</H2>
Your login and password:
<br><br>
<div id="login-name" style="margin-top:20px;">Login:</div><div id="login-fld" style="margin-top:20px;"><input name="username" class="form-login" title="Username" value="" size="30" maxlength="2048" /></div>
<div id="login-name">Pass:</div><div id="login-fld"><input name="password" type="password" class="form-login" title="Password" value="" size="30" maxlength="2048" /></div>
<br><br><br>
<input type="image" src="obr/login-klw.png" alt="Submit" width="103" height="42" style="margin-left:90px;">
<br><br>
<?php if ($_GET["log_err"]) { if ($_GET["rsn"] == "pass") { ?>
<html><body><h3>Error no 1</h3></body></html>
<?php } else { ?>
<html><body><h3>Error no 2</h3></body></html>
<?php } exit; } ?>
</form>
和PHP代碼:
... [ question to the database and return in $result object ] ...
if ($result->num_rows == 0) {
setcookie('logged_in', false, time() + 600, '/');
die(header("location:../index.html?log_err=true&powod=pass"));
}
else {
setcookie('logged_in', $_POST['username'], time() + 600, '/');
header("Location: /AAA/app.html");
}
}
else {
setcookie('logged_in', false, time() + 600, '/');
die(header("location:../index.html?log_err=true&powod=empty"));
}
和兩個消息(「錯誤號1」和「錯誤號2」)我看,每次我加載 此頁。我不知道爲什麼以及如何調試這部分代碼。任何人都可以幫助我?
我看到錯誤的按摩所有的時間。
請粘貼整個代碼 – Blueblazer172
爲什麼使用$ _GET? –
你把'
.....'裏面的''。 – Banzay