客戶端登錄此頁面時出現問題。這些人被分配一個號碼,不管他們的號碼是什麼,他們都得到一個空白頁。如果他們輸入密碼無效,他們會收到無效的密碼信息,所以我知道部分代碼正在工作。我還在瀏覽器中驗證了每個客戶端應該實際運行的目標。任何幫助你可以提供將不勝感激!使用PHP登錄頁面時遇到問題
<Doctype HTML>
<html>
<head>
<?php
//include the required functions
include(' ./includes/functions.php');
//make connection
$db = conn();
//check for username and password
if(isset($_POST['username']) && isset($_POST['password'])) {
//Query the db for the user
$result = $db->query("SELECT * FROM users WHERE username ='{$_POST['username']}'");
//fetch the result set
$row = $result->fetch_assoc();
//check credentials again the database
if ($result == true && md5($_POST['password']) == $row['password']){
//store user as seesion variable
$_SESSION['valid_user'] = $_POST['username'];
/*
* @Locations:
* /admin, /calc, /live
*
* @Authorization Levels
* 1 = production employee
* 2 = Quality tech
* 3 = Management
* 0 = not authorized
*
* @var = $row['active']
*/
if ($row['active'] == '3') {
header('Location: ./admin/index.php ');
}
elseif ($row['active'] == 2) {
header('Location: ./calc/index.php ');
}
elseif ($row['active'] == 1) {
header('Location: ./live/data.php ');
}
}
elseif ($_POST['password'] != $row['password']) {
echo ('Password Incorrect');
}
}
else
{
?>
<style type="text/css">
body
{
margin: 0;
/* IE10 */
background-image: -ms-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
background-repeat: no-repeat;
/* Mozilla Firefox */
background-image: -moz-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
background-repeat: no-repeat;
/* Opera */
background-image: -o-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #FFFFFF), color-stop(1, #7EBC50));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
/* Proposed W3C Markup */
background-image: linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
/* IE6-IE9 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#7EBC50', EndColorStr='#FFFFFF');
}
#login
{
background-color: #FBFBCA;
width: 15em;
margin-right: auto;
margin-left: auto;
margin-top: 15%;
margin-bottom: auto;
border: 2px solid #3A8E00;
border-radius: 5px;
text-align: center;
padding-bottom: 1em;
box-shadow: 10px 10px 5px #888888;
-moz-box-shadow: 10px 10px 5px #888888;
}
#login .text, h4
{
color: #1C4F00;
font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;
}
</style>
<title>LLF Lab || Login Page</title>
</head>
<body>
<div id="login">
<h4>LLF Lab Login</h4>
<form action="login.php" method="post">
<span class="text">Username:</span><br />
<input type="text" name="username"/><br />
<br />
<span class="text">Password:</span><br />
<input type="password" name="password"/>
<br />
<br />
<input type="checkbox" name="rememberme"/><span class="text">Remember me</span>
<br />
<br />
<input type="submit" value="Login" />
</form>
</div>
</body>
</html>
<?php
}//endif ?>
請正確格式化您的代碼。 – Hamish
CSS不是必需的(除非它沒有工作)。還有SQL注入;谷歌了數據庫轉義,或使用PDO /準備語句,以避免這種繁瑣和過時的方法。 – mario
你不應該在你的查詢中使用*。 – DarthVader