PHP显示重复的jQuery元素

时间:2013-07-06 21:26:56

标签: php jquery session jquery-mobile redirect

成功登录后,我遇到了页面元素重复问题。登录后,页面会加载,但会显示按钮和页脚的重复项。此外,如果我删除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();
?>

1 个答案:

答案 0 :(得分:0)

androidIMFeed.php

中添加此代码
<?php
  session_start();
  if ( !isset( $_SESSION['login_user'] ) ) {
    include_once('androidLogin.php');
    exit();
  }
  ob_start();
?>

而不是

<?php
ob_start();
//start output buffering 
include_once('androidLogin.php');
?>