1

客户在登录此页面时遇到问题。他们被分配了一个号码,无论他们的号码是多少,他们都会得到一个空白页。如果他们输入无效密码,他们会收到无效的密码消息,所以我知道部分代码正在运行。我还在浏览器中验证了每个客户端应该去的实际目的地是否正常工作。您能提供的任何帮助将不胜感激!

<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 ?>
4

2 回答 2

2

将 HTML 输出到浏览器后,您正在使用 header()。移动

<Doctype HTML>
<html>
<head>

在 PHP 代码下方。

于 2012-07-02T20:48:22.337 回答
1

header("location: example.html")仅在未打印任何其他内容时才有效。因为您在 之前打印文档类型(这也是不正确的<!DOCTYPE html>header(),所以它永远不会重定向。将打开的 html 移到 php.ini 下。

于 2012-07-02T20:49:36.047 回答