2015-08-08 26 views
1

爲了給您一個簡短的背景,我正在使用推薦程序,其主要功能是指某人。此修改標題的錯誤

在我的網站。我有註冊頁面,登錄頁面,成功註冊頁面,推薦頁面和推薦列表。

例如,如果您是用戶,您必須通過註冊頁面進行註冊。如果您在我的頁面上成功註冊,則下一頁將成爲註冊頁面。有一個按鈕可以轉到推薦頁面以引用某人。

我遇到的問題是,我註冊爲新用戶。所以當然,我填寫了所有必要的信息到註冊頁面,成功註冊後,下一頁顯示註冊成功頁面,在該頁面有一個按鈕,一旦您點擊它,它將轉到推薦表單頁面。

例如,我現在指一個人,所以我充滿了所有的信息,所以,當我試圖向我的推薦有一個錯誤,提示在我的網頁

誰能告訴我這是我的代碼行被觸發這個錯誤:

Warning: Cannot modify header information - headers already sent by (output started at /home/thecommissioner/public_html/crm/include/Webservices/Utils.php:880) in /home/thecommissioner/public_html/crm/modules/Webforms/capture_old.php on line 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> 

錯誤:

Warning: Cannot modify header information - headers already sent by (output started at /home/thecommissioner/public_html/crm/include/Webservices/Utils.php:880) in /home/thecommissioner/public_html/crm/modules/Webforms/capture_old.php on line 97

只是表明我的,上面的警告/錯誤沒有後指,當我提到更多的第一次嘗試再次顯示。

如果這些警告只顯示在我的第一次引薦嘗試,爲什麼它不顯示下次我再次提及?這只是我第一次嘗試。

+0

使用輸出緩衝 – RamRaider

+0

讓我來試試吧。謝謝@RamRaider – arci

+0

http://stackoverflow.com/questions/31890219/vague-error-in-cannot-modify-header-information – mario

回答

0

您需要在ANY輸出發送之前發送標題。這意味着在頁面頂部的HTML之前。

或者,如RamRider所示,使用輸出緩衝。

ob_start() 

在頁面的最頂端和

ob_end_clean() 

在最底部

+0

那麼我的代碼的安排應該是什麼? – arci

+0

顯示錯誤頁面的代碼。你在哪裏包括他們? – david8

+0

包含在我的CRM中,它由百行代碼組成。你介意看看嗎? – arci

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 link

+0

謝謝@Jijo John。我會更新你。 – arci

+0

歡迎你:) :) –

+0

你好。我嘗試了你的建議,仍然得到相同的錯誤。 – arci