已登录,如果你设置了POST,你将重定向到一个页面......但标题(" Location:page.php");似乎没有用,我也不知道为什么......你能帮帮我吗?
以下代码:
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$passwordantiscam = mysql_real_escape_string($_POST['passwordantiscam']);
$usernamep = mysql_query("SELECT username FROM users WHERE username = '".$username."' AND rank > 7");
$passwordp = mysql_query("SELECT password FROM users WHERE username = '".$username."' AND password = '".$password."' AND rank > 7");
$passwordantiscamp = mysql_query("SELECT password_antiscam FROM admin_pswantiscam WHERE password_antiscam = '".$passwordantiscam."'");
if(isset($_POST['login'])) {
if(empty($username) && empty($password) && empty($passwordantiscam)) {
echo '<div class="error">Hai lasciato qualche campo vuoto</div>';
} else {
if(mysql_num_rows($usernamep) == 0) {
echo '<div class="error">Nome utente sbagliato</div>';
} else {
if(mysql_num_rows($passwordp) == 0) {
echo '<div class="error">Password sbagliata</div>';
} else {
if(mysql_num_rows($passwordantiscamp) == 0) {
echo '<div class="error">Password anti-scam sbagliata</div>';
} else {
$check = mysql_query("SELECT id,username FROM users WHERE username = '" . $username. "' AND password = '" . $password. "' AND rank > 7 LIMIT 1") or die(mysql_error());
$row = mysql_fetch_assoc($check);
session_start();
$_SESSION['acp'] = true;
$_SESSION['hkusername'] = $row['username'];
$_SESSION['hkpassword'] = $password;
$my_id = $row['id'];
if(!session_is_registered(username)){
$_SESSION['username'] = $row['username'];
$_SESSION['password'] = $password;
}
header("Location: home.php");
mysql_query("INSERT INTO system_stafflog (action,message,note,userid,targetid,timestamp) VALUES ('Housekeeping','".$_SESSION['hkusername']." authenticated from ".$remote_ip."','login.php','".$my_id."','','".$date_full."')") or die(mysql_error());
exit;
}
}
}
}
}
我已经读过标题必须放在输出之前..但如果我这样做,代码将重定向BEFORE以启动会话...我该如何解决这个问题?