我想在登录后将用户重定向到页面,但我总是收到“无法修改标题”错误。我知道在命令之前不应该有回声或其他东西,header()
但它是如何以正常方式完成的。用户登录,设置 cookie(也设置了会话),用户收到通知,所有事情都按正确的方式进行,他将被重定向到另一个页面?
这是我的 php 文件:
<?php
$qry="SELECT * FROM user WHERE email='$email' AND password='".md5($_POST['password'])."'";
$result=mysql_query($qry);
if($result) {
if(mysql_num_rows($result) == 1) {
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['id'];
$_SESSION['EMAIL'] = $member['email'];
session_write_close();
if($remember_me == 1) {
setcookie("user",$email,time()+(3600*24*365));
setcookie("pw",md5($_POST['password']),time()+(3600*24*365));
}
//header("location: logged.php"); <- doesn't work
echo 'you are now logged in';
}
else {
echo 'something went wrong';
}
}
else {
die("Query failed");
}
}
?>
提前致谢。最好的问候,约翰。