2016-01-21 98 views
-2

遇到會話變得非常煩人的問題。每次嘗試在特定頁面上啓動會話時,出現以下錯誤:消息:session_start():無法發送會話緩存限制器 - 已發送的頭文件

警告:session_start():無法發送會話緩存限制器 - 已發送的頭文件(輸出在/ home/uplbcdcn/public_html/CDC /警告:不能修改標題信息 - 已經發送的標題(在/ home/uplbcdcn /的public_html/CDC/admin_uplbcdc/header.php文件:57)在/home/uplbcdcn/public_html/CDC/admin_uplbcdc/index.php第42行

這裏是代碼:的header.php

<!DOCTYPE html> 
<html> 
<head> 
     <title>UPLB Credit and Development Cooperative</title> 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <!-- Bootstrap --> 
      <link href="../css/bootstrap.css" rel="stylesheet" media="screen"> 
      <link href="../css/bootstrap-responsive.css" rel="stylesheet" media="screen"> 
      <link href="../css/docs.css" rel="stylesheet" media="screen"> 
      <link href="../css/diapo.css" rel="stylesheet" media="screen"> 
      <link href="../css/font-awesome.css" rel="stylesheet" media="screen"> 
      <link rel="stylesheet" type="text/css" href="../css/style.css" /> 
      <link rel="stylesheet" type="text/css" href="../css/DT_bootstrap.css" /> 
      <link rel="stylesheet" type="text/css" media="print" href="../css/print.css" /> 

    <!-- js -->   
    <script src="../js/jquery-1.7.2.min.js"></script> 
    <script src="../js/bootstrap.js"></script> 
    <script src="../js/jquery.hoverdir.js"></script> 

<script> 
jQuery(document).ready(function() { 
$(function(){ 
    $('.pix_diapo').diapo(); 
}); 
}); 
</script> 
    <noscript> 
      <style> 
       .da-thumbs li a div { 
        top: 0px; 
        left: -100%; 
        -webkit-transition: all 0.3s ease; 
        -moz-transition: all 0.3s ease-in-out; 
        -o-transition: all 0.3s ease-in-out; 
        -ms-transition: all 0.3s ease-in-out; 
        transition: all 0.3s ease-in-out; 
       } 
       .da-thumbs li a:hover div{ 
        left: 0px; 
       } 
      </style> 
     </noscript>  

    <script type="text/javascript" charset="utf-8" language="javascript" src="../js/jquery.dataTables.js"></script> 
    <script type="text/javascript" charset="utf-8" language="javascript" src="../js/DT_bootstrap.js"></script> 
    <script type='text/javascript' src='../scripts/jquery.easing.1.3.js'></script> 
<script type='text/javascript' src='../scripts/jquery.hoverIntent.minified.js'></script> 
<script type='text/javascript' src='../scripts/diapo.js'></script> 


<!--sa calendar--> 
     <script type="text/javascript" src="../js/datepicker.js"></script> 
     <link href="../css/datepicker.css" rel="stylesheet" type="text/css" /> 

</head> 
<?php include('dbcon.php'); ?> 
<body> 


index.php 

<?php include('header.php'); ?> 
<?php include('navbar.php'); ?> 
    <div class="container"> 
     <div class="margin-top"> 
      <div class="row"> 
      <div class="span12"> 

       <div class="login"> 
       <div class="log_txt"> 
       <p><strong>Please Enter the Details Below..</strong></p> 
       </div> 
         <form class="form-horizontal" method="POST"> 
           <div class="control-group"> 
            <label class="control-label" for="inputEmail">Username</label> 
            <div class="controls"> 
            <input type="text" name="username" id="username" placeholder="Username" required> 
            </div> 
           </div> 
           <div class="control-group"> 
            <label class="control-label" for="inputPassword">Password</label> 
            <div class="controls"> 
            <input type="password" name="password" id="password" placeholder="Password" required> 
           </div> 
           </div> 
           <div class="control-group"> 
            <div class="controls"> 
            <button id="login" name="submit" type="submit" class="btn"><i class="icon-signin icon-large"></i>&nbsp;Submit</button> 
           </div> 
           </div> 

           <?php 
           if (isset($_POST['submit'])){ 
           session_start(); 
           $username = $_POST['username']; 
           $password = $_POST['password']; 
           mysqli_select_db($dbcon,$database_dbcon); 
           $query = "SELECT * FROM users WHERE username='$username' AND password='$password'"; 
           $result = mysqli_query($dbcon,$query)or die(mysqli_error()); 
           $num_row = mysqli_num_rows($result); 
            $row=mysqli_fetch_array($result); 
            if($num_row > 0) { 
             header('location:dashboard.php'); 
           $_SESSION['id']=$row['user_id']; 
            } 
            else{ ?> 
           <div class="alert alert-danger">Access Denied</div>  
           <?php 
           }} 
           ?> 
         </form> 

       </div> 
      </div>  
      </div> 
     </div> 
    </div> 
<?php include('footer.php') ?> 
+0

在'<?php'標籤後面寫上'session_strat();'在頁面的頂部,並且在文件的最後一行刪除空行。 –

+0

添加'session_start()'行開頭的文件。 –

回答

0

有兩件事情,你可以嘗試

1)寫在上面,使用session_start()。

2)在使用標題時使用出口
exit(header('location:dashboard.php'));

相關問題