我有一個類似的代碼如下:
<?php
require 'database/db.php';
if($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["userid"];
$password = $_POST["password"];
if (empty($name) || empty($password)) {
header("Location : AdminLogin.php?status=failure");
exit();
}
$count = verifyUser($name, $password);
if($count == 1)
{
header("Location : AdminLogin.php?status=success");
}
else {
header("Location : AdminLogin.php?status=failure");
}
exit;
}
?>
<?php include('inc/header.php'); ?>
<div class = "section page">
<div class ="wrapper">
<div class="page-header">
<b>Admin Login </b>
</div>
<?php if(isset($_GET["status"]) AND $_GET["status"]=="success") { ?>
<p> Your login was a success .. I will redirect you to another page.</p>
<?php } else {?>
<form method="post" class="form-signin" action="AdminLogin.php">
<h2 class="form-signin-heading">Sign In</h2>
<input type="text" name ="userid" class="input-block-level" placeholder="UserID...">
<input type="password" name ="password" class="input-block-level" placeholder="Password...">
<button class="btn btn-large btn-primary" type="submit">Sign in</button>
</form>
<?php } ?>
</div>
</div>
<?php include('inc/footer.php'); ?>
當我點擊登錄按鈕,我執行了服務器端的用戶進行驗證,並返回一個int (應該是bool,我同意)登錄是否成功。
我正在重定向到同一頁面。
調查結果...
我已驗證$ count是否正確返回。即如果用戶名和密碼匹配count = 1 else count!= 1。到現在爲止還挺好。我也注意到它在那之後失敗了。
感謝 加甘
編輯:verifyUser(這只是一個存根)
function verifyUser($username, $password)
{
return strcmp ($username , $password)
}
你如何向我們展示'verifyUser' – Kermit 2013-02-26 01:39:43
你的混音帖子並獲得。選擇和堅持它 – 2013-02-26 01:40:40
@AarolamaBluenk:我很確定verifyuser工作..它只有3行代碼(基本上是一個存根)..所以沒有樂趣那裏張貼.. – Gagan 2013-02-26 01:42:17