PHP header()的另一种方式是什么?


what is the another way of php header()

我知道,在发送任何实际输出之前必须调用header()。但是我正在尝试使用header()在我的xammp服务器中包含会话。代码是:

<>之前 $member_id=$_REQUEST['member_id']; $member_id = stripslashes($member_id); $sql="SELECT * FROM member WHERE member_id='$member_id'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ $_SESSION['member_id']=$member_id; header("location:index.php?page=member_account&&member=success"); } 之前

上面的代码在我的本地主机上运行良好。但是当我在在线服务器上上传这个脚本时,服务器显示一个警告,看起来像这样:警告:无法修改头信息-头已经由(输出开始于/home/emonuniq/public_html/index.php:16)在/home/emonuniq/public_html/inc/member/check.php第15行发送。然后我尝试用另一种方式在javascript上重定向这个链接。

<>之前 //script tag is not showing echo("location.href = 'index.php?page=member_account&&member=success'; "); 之前

此代码在success.php上重定向成功。但是在本页会话不工作。我该怎么办?

添加到php.ini

output_buffering = On

这可能对你有帮助:

<script>
  window.location.href = "index.php?page=member_account&&member=success";
</script>