此修改标题

时间:2015-08-08 12:47:23

标签: php html

为了给你一个简短的背景,我正在使用推荐计划,它的主要特点就是推荐某人。

在我的网站上。我有注册页面,登录页面,成功注册页面,推荐页面和推荐列表。

例如,如果您是用户,则必须通过注册页面注册。如果您在我的页面上成功注册,则下一页将是成功注册页面。那里有一个按钮可以转到推荐页面来推荐某人。

我遇到的问题是,我注册为新用户。所以当然,我填写了所有必要的信息到注册页面,在我成功注册后,下一页显示成功的注册页面,在该页面中有一个按钮,一旦你点击它,它将转到推荐表单页面

例如,我现在会推荐某人,所以我填写了所有信息,所以当我尝试提交推荐时,我的页面上会出现错误提示

任何人都可以告诉我我的代码的哪一行触发了这个错误:

  

警告:无法修改标头信息 - 已发送的标头   (输出始于   /home/thecommissioner/public_html/crm/include/Webservices/Utils.php:880)   在   /home/thecommissioner/public_html/crm/modules/Webforms/capture_old.php   在第97行

但推荐在我的推荐列表中添加,所以当我再次尝试推荐时,此错误将不再显示...即使我多次提及,此错误也不再显示。它只显示在新创建的帐户的第一次推荐尝试。我不知道问题是什么。

这只是在我第一次尝试引用某人时显示,但在那之后,当我试图推荐更多时,这不再显示,我已经添加了我的推荐。有人能帮我解决这个问题吗?

我知道那里有几个课程,我已经在stackoverflow中阅读了不同的帖子,我对它仍然含糊不清。您是否介意告诉我我可以使用哪些新代码而不是当前代码?因为这个原因,我无法测试我的页面是否正常工作。

这是我的代码:

<!DOCTYPE html>
<?php
include('../include/dbconnection.php');
include('../include/functions.php');

if(!isset($_SESSION))
{
session_start();
}
$empid = $_SESSION['SESS_EMP_ID'];
$conid = $_SESSION['SESS_CONID'];
$fName = $_SESSION['SESS_FIRSTNAME'];
$lName = $_SESSION['SESS_LASTNAME'];
$contactNo = $_SESSION['SESS_CONTACT_NO'];
$mobile = $_SESSION['SESS_MOBILE'];
$email = $_SESSION['SESS_EMAIL'];
$bday = $_SESSION['SESS_BDAY'];

if($conid == '')
{
echo ("<SCRIPT LANGUAGE='JavaScript'>
    window.location.href='index.php';
    </SCRIPT>");
}

else
{
//Nothing
}
?>
<html lang="en">

<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="../css/normalize.css">
<link rel="stylesheet" href="../css/skeleton.css">
<link rel="stylesheet" href="../css/successReg_style.css">
<link rel="icon" type="image/png" href="../images/cvglogo.png">
<link rel="short icon" href="../images/favicon.ico">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript"></script>
<link rel="stylesheet" href="../css/animate.css">
</head>

<body>

 <!--Here the Header goes-->
 <?php include('include/logoheader.php'); ?>


    <!-- Overall Contect for Responsive Purposes-->
    <div class="allcontent">
        <div class="row">
                <div class="twelve columns" style="margin-top:0%;">

                    <!-- Here the Main Content goes-->
                    <div="maincontent">
                        <center>
                            <h3>Congratulations and Welcome to the Circle!</h3>
                            <br>

                            <div class=" animated zoomIn socialmedia">
                                <ul>
                                    <li>
                                    <img class="logos" src="../images/tick.png">
                                    </li>  
                                </ul>
                            </div>

                            <!-- This is the welcome Introduction -->
                            <div class="welcome">
                                <p>Now that you’re part of the most awesome group on the planet, why not share the glory with your friends. There’s no happier  
                                team 
                                player than a team player with his friends.</p>
                                <span class="hit">Don’t be shy. Hit the button. Refer your friend!</span><br>


                <!-- This is Just a GIF arrow down -->
                            <div class="demo-wrapper">
                                <div class="html5-dialog">
                                        <div class="gif">
                                            <img src="../images/scroll-down.gif">
                                        </div>
                                        <?php include('GlobalConstant.php'); ?>
                                        <!-- But here goes the button for "I have someone in mind" -->
                                        <a href="<?php echo employee_refer; ?>"><button class="navbutton">I have someone in mind</button>   
                                        </a>
                                </div>
                         </div>
                </div>
        </div>
 </div>

             <!-- Here the footer goes-->
         <center><?php include("include/footer.php"); ?></center>

 </body>
 </html>

错误:

  

警告:无法修改标头信息 - 已发送的标头   (输出始于   /home/thecommissioner/public_html/crm/include/Webservices/Utils.php:880)   在   /home/thecommissioner/public_html/crm/modules/Webforms/capture_old.php   在第97行

只是在我第一次尝试引用之后显示,之后,当我提到更多时,上述警告/错误没有再显示。

如果这些警告只是在我第一次尝试引用时显示,为什么下次再次引用时它不显示?它只是在我第一次尝试时显示。

2 个答案:

答案 0 :(得分:0)

您需要在发送任何输出之前发送标头。这意味着在HTML之前,在页面顶部。

或者,正如RamRider建议的那样,使用输出缓冲。

ob_start() 

在页面顶部和

ob_end_clean() 

在最底层

答案 1 :(得分:0)

您需要将session_start()函数放在代码的顶部。否则有时php会抛出已发送的异常头。

    <?php
    session_start();

    include('../include/dbconnection.php');
    include('../include/functions.php');


    $empid = $_SESSION['SESS_EMP_ID'];
    $conid = $_SESSION['SESS_CONID'];
    $fName = $_SESSION['SESS_FIRSTNAME'];
    $lName = $_SESSION['SESS_LASTNAME'];
    $contactNo = $_SESSION['SESS_CONTACT_NO'];
    $mobile = $_SESSION['SESS_MOBILE'];
    $email = $_SESSION['SESS_EMAIL'];
    $bday = $_SESSION['SESS_BDAY'];

    if($conid == '')
    {
    echo ("<SCRIPT LANGUAGE='JavaScript'>
        window.location.href='index.php';
        </SCRIPT>");
    }

    else
    {
    //Nothing
    }
    ?>
   <!DOCTYPE html>
    <html lang="en">

    <head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="../css/normalize.css">
    <link rel="stylesheet" href="../css/skeleton.css">
    <link rel="stylesheet" href="../css/successReg_style.css">
    <link rel="icon" type="image/png" href="../images/cvglogo.png">
    <link rel="short icon" href="../images/favicon.ico">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
    <script type="text/javascript"></script>
    <link rel="stylesheet" href="../css/animate.css">
    </head>

    <body>

     <!--Here the Header goes-->
     <?php include('include/logoheader.php'); ?>


        <!-- Overall Contect for Responsive Purposes-->
        <div class="allcontent">
            <div class="row">
                    <div class="twelve columns" style="margin-top:0%;">

                        <!-- Here the Main Content goes-->
                        <div="maincontent">
                            <center>
                                <h3>Congratulations and Welcome to the Circle!</h3>
                                <br>

                                <div class=" animated zoomIn socialmedia">
                                    <ul>
                                        <li>
                                        <img class="logos" src="../images/tick.png">
                                        </li>  
                                    </ul>
                                </div>

                                <!-- This is the welcome Introduction -->
                                <div class="welcome">
                                    <p>Now that you’re part of the most awesome group on the planet, why not share the glory with your friends. There’s no happier  
                                    team 
                                    player than a team player with his friends.</p>
                                    <span class="hit">Don’t be shy. Hit the button. Refer your friend!</span><br>


                    <!-- This is Just a GIF arrow down -->
                                <div class="demo-wrapper">
                                    <div class="html5-dialog">
                                            <div class="gif">
                                                <img src="../images/scroll-down.gif">
                                            </div>
                                            <?php include('GlobalConstant.php'); ?>
                                            <!-- But here goes the button for "I have someone in mind" -->
                                            <a href="<?php echo employee_refer; ?>"><button class="navbutton">I have someone in mind</button>   
                                            </a>
                                    </div>
                             </div>
                    </div>
            </div>
     </div>

                 <!-- Here the footer goes-->
             <center><?php include("include/footer.php"); ?></center>

     </body>
     </html>

如果您仍然遇到问题,请尝试ob_start()和ob_flush()..无论如何,有关已发送标头的stackoverflow文章值得一读Stackoverflow link