我在 PHPsessions
中遇到了一个非常讨厌的问题。includes
我有一个页面调用,我在不同页面之间index.php
有一个函数:switch
<?php $p=(isset($_GET["p"])?$p=intval($_GET["p"]):$p=1); switch($p) {
case 1: $pagina = "login_and_registration.php";
break;
case 2: $pagina = "admin/registrazione.php";
break;
case 3: $pagina = "admin/login_test.php";
break;
case 4: $pagina = "logged_gym.php";
break;
case 5: $pagina = "logged_trainer.php";
break;
case 7: $pagina = "logout.php";
break;
case 8: $pagina = "admin/completa_profilo_trainer_sql.php";
break;
case 10: $pagina = "error.php";
break;
case 12: $pagina = "profilo_min.php";
break;
case 13: $pagina = "splash.php";
break;
default: $pagina = "index.php";
break;} ?>
然后在文件正文中的代码我有一些包括:
<header class="container_12">
<?php include("login_errors.php")?>
<div id="logo_container" class="grid_4 push_4"></div></header >
和这个:
<section>
<?php include_once($pagina);?>
</section>
当我填写此页面中的表单时,对应于 switch 功能中的第 1 页,我在登录时收到此错误(我开始一个带有名称的新会话):
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /Applications/MAMP/htdocs/FitnessOptimize/index.php:63) in /Applications/MAMP/htdocs/FitnessOptimize/admin/login_test.php on line 73
在第 63 行的 index.php 中,我有include
我刚刚发布的第一个。关于如何避免这个错误的任何想法?也是我的header ("Location: ")
;不工作我认为出于同样的原因。任何帮助将不胜感激!谢谢大家!