成功登录后,我遇到了页面元素重复的问题。登录后,页面加载但按钮和页脚重复。此外,如果我删除 jQuery 数据角色页面元素,我可以看到当前页面元素后面的登录表单。我已经附加了登录信息,然后是预期的成功登录页面重定向(忽略安全问题)。请让我知道我是否正确处理会话以携带用户名以及如何解决此重复问题。如果需要更多信息,请告诉我。
登录:
<?php
//start output buffering
ob_start('ob_gzhandler');
?>
<!DOCTYPE html>
<html>
<head >
<meta name="robots" content="noindex, nofollow"/>
<LINK REL=StyleSheet HREF="hourslog.css" TYPE="text/css">
<title>Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="themes/shipshape.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile.structure-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<?php
// Connect to server and select databse.
$con = mysql_connect('***','***','***');
mysql_select_db("***")or die("cannot select DB");
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$myusername=addslashes($_POST['username']);
$mypassword=addslashes($_POST['password']);
$sql="SELECT * FROM Users WHERE username = '" . $myusername . "' AND password = '" . $mypassword . "' AND block_status < 1";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$active=$row['active'];
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count>0)
{
$_SESSION['login_user']=$myusername;
header("location: /androidIMFeed.php");
}
else
{
$error="Your Login Name or Password is invalid";
}
}
?>
<form action="" method="post" data-ajax="false">
<input type="text" name="username" placeholder="Username" required/><br />
<input type="password" name="password" placeholder="Password" required/><br/>
<input type="submit" value=" Submit "/><br />
</form>
</body>
</html>
<?php
//end output buffering
ob_end_flush();
?>