在我的索引上,我有一个jQuery脚本将文件加载到我的包装器div中。但是如果我将submit2.php
加载到div中并且文件中有标题(位置),它会将页面重定向到div。但是,我希望整个页面重定向为_self
<a>
链接。
任何方式绕过这个或我做错的事情干扰它?
用于将文件加载到div中的jQuery脚本:
<script>
$(document).ready(function() {
var trigger = $('#nav ul li a'), container = $('#wrapper');
trigger.on('click', function() {
var $this = $(this), target = $this.data('target');
container.load(target + '.php');
return false;
});
});
</script>
submit2.php
<?php
session_start();
include('config.php');
$con = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
$error = "";
if (empty($_POST['username']) || empty($_POST['pass'])) {
$error = "Both fields are required.";
} else {
$loginpass = md5($_POST['pass']);
$user = $_POST['username'];
$sql="SELECT * FROM user WHERE username='$user'";
$result=mysqli_query($con,$sql);
$checkuser=mysqli_num_rows($result);
if($checkuser!=1) {
$error = "username doesn't exist in our database!";
}
while($row=mysqli_fetch_array($result)) {
$checkpass = $row['password'];
$user_id = $row['id'];
$level = $row['usergroup'];
if ($loginpass == $checkpass) {
$_SESSION['login_user'] = $user;
$_SESSION['user_id'] = $user_id;
$_SESSION['start'] = time();
$_SESSION['user_level'] = $level;
echo ("succesfully logging in");
header("Location: panel/index.php");
} else {
$error = "Incorrect Password!";
}
}
}
感谢。