警告:session_start():无法发送会话缓存限制器 - 已发送的标头

时间:2017-08-21 04:50:43

标签: php html session login

enter image description here

  

这是错误: - 警告:session_start():无法发送会话缓存限制器 - 已在/ home / solifotech /中发送的标头(在/home/solifotech/meraapp.solidaleinfotech.com/myBills.php.2中开始输出) meraapp.solidaleinfotech.com/myBills.php.3

     

这是我的代码

 
<?php
session_start();
 
  

 include('dbConfig.php');

  
 
 if (!isset($_SESSION["userEmailid"]))
 {
	 header('LOCATION:main_login.php'); 
	 exit();
 }
 $userEmailid=$_SESSION["userEmailid"];
 
 
 $Q2=mysql_query("SELECT * FROM user where user_email='$userEmailid'");
 while($row = mysql_fetch_array($Q2)){
	 $userName=$row['user_name'];
	 $user_id=$row['user_id'];
	 $userEmail=$row['user_email'];
 } 
	
	 
?>
<?php include('header.php');?>
<body>
  <section class="w-section mobile-wrapper">

    <div class="page-content" id="main-stack">
      <div class="w-nav navbar" data-collapse="all" data-animation="over-left" data-duration="400" data-contain="1" data-easing="ease-out-quint" data-no-scroll="1">
        <div class="w-container">
		<?php include('navbar.php');?>
         <!--- <nav class="w-nav-menu nav-menu" role="navigation">
            <div class="nav-menu-header">
              <div class="logo">Mera App</div>
              <div class="slogan">All you need is here.</div>
            </div>
            <a class="w-clearfix w-inline-block nav-menu-link" href="index.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-home-outline"></div>
              </div>
              <div class="nav-menu-titles">Splash Screen</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="login.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-download-outline"></div>
              </div>
              <div class="nav-menu-titles">Login</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="signup.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-cloud-upload-outline"></div>
              </div>
              <div class="nav-menu-titles">Sign Up</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="forgot.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-unlocked-outline"></div>
              </div>
              <div class="nav-menu-titles">Remember Password</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="todo-list.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-list-outline"></div>
              </div>
              <div class="nav-menu-titles">To Do List</div>
              <div class="nav-menu-text-right">8</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="addnew.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-checkmark-outline"></div>
              </div>
              <div class="nav-menu-titles">New To Do</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="messages.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-albums-outline"></div>
              </div>
              <div class="nav-menu-titles">Messages</div>
              <div class="nav-menu-text-right">8</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="chat.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-chatboxes-outline"></div>
              </div>
              <div class="nav-menu-titles">Chat</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="groups.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-keypad-outline"></div>
              </div>
              <div class="nav-menu-titles">News Groups</div>
              <div class="nav-menu-text-right">12</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="news.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-paper-outline"></div>
              </div>
              <div class="nav-menu-titles">News List</div>
              <div class="nav-menu-text-right">14</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="newitem.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-compose-outline"></div>
              </div>
              <div class="nav-menu-titles">News Post</div>
              <div class="nav-menu-text-right">14</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="about-us.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-person-outline"></div>
              </div>
              <div class="nav-menu-titles">About the App</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="maps.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-location-outline"></div>
              </div>
              <div class="nav-menu-titles">Maps</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="elements.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-box-outline"></div>
              </div>
              <div class="nav-menu-titles">Elements</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link" href="settings.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-gear-outline"></div>
              </div>
              <div class="nav-menu-titles">Settings</div>
            </a>
            <a class="w-clearfix w-inline-block nav-menu-link last" href="terms.html" data-load="1">
              <div class="icon-list-menu">
                <div class="icon ion-ios-bookmarks-outline"></div>
              </div>
              <div class="nav-menu-titles">Terms and Conditions</div>
            </a>
            <div class="separator-bottom"></div>
            <div class="separator-bottom"></div>
            <div class="separator-bottom"></div>
          </nav>---->
          <div class="wrapper-mask" data-ix="menu-mask"></div>
          <div class="navbar-title">My Bills</div>
          <div class="w-nav-button navbar-button left" id="menu-button" data-ix="hide-navbar-icons">
            <div class="navbar-button-icon home-icon">
              <div class="bar-home-icon"></div>
              <div class="bar-home-icon"></div>
              <div class="bar-home-icon"></div>
            </div>
          </div>
        </div>
      </div>
      <div class="body">
      <div class="logo-login"></div>
        
         
          <!--<div class="w-tab-content tabs-content">
            <div class="w-tab-pane w--tab-active w-clearfix tab-pane" data-w-tab="Tab 1">
              <div class="group-block">
                <a class="w-inline-block" href="#" data-load="1">
                 
                  <div class="group-title">
                    <div class="title-text" style="padding:5px 5px; color:#FFF; background:#4fd2c2; text-align:center">My Manuals</div>

                  </div>
                </a>
              </div>
              <div class="group-block last">
                <a class="w-inline-block" href="#" data-load="1">
                 
                  <div class="group-title">
                    <div class="title-text" style="padding:5px 5px; color:#FFF; background:#4fd2c2; text-align:center">My Bills</div>
                  </div>
                </a>
              </div><br>
            <center> <div class="group-block last" style="margin-top:20px; margin-left:60px">
                <a class="w-inline-block" href="#" data-load="1">
                 
                  <div class="group-title">
                    <div class="title-text" style="padding:5px 5px; color:#FFF; background:#4fd2c2; text-align:center">My Warrenty Cards</div>
                  </div>
                </a>
              </div></center>
              
            </div>
            
          </div>---->
		  <?php
		  include('dbConfig.php');
		  ?>
		  <?php
   
if(isset($_POST['upload']))
{ 



/// File Add
$bills_file = $_FILES['billscopy']['name'];


// file Temp 
$tembills_file =$_FILES['billscopy']['tmp_name'];

//uploading image to its folder

move_uploaded_file($tembills_file,"mybills/$bills_file");

mysql_query("INSERT INTO `mybills`(`user_id`, `user_name`, `user_email`, `bills_copy`) 
 VALUES ('$user_id','$userName','$userEmail','$bills_file')") or die(mysql_error());
 echo "<div class='alert alert-success'>Bills Copy Added Successfully.</div>";
}


?>
	 

	
<style>
    form input[type="file"] {
          display: none;
        }
		</style>
           <div class="w-tabs" data-duration-in="400" data-duration-out="400" data-easing="ease-out-quint">
           <form method="post"  enctype="multipart/form-data" action="#">
              <div>
                <center><label for="fileToUpload">
      <img src="upload_img.png" width="70px" height="70px" />
    </label>
    <input type="File" name="billscopy" id="fileToUpload" accept="image/*" capture="camera" data-name="full-name" required></center>
   <br>
                <!---<center><input class="form-control" id="full-name-field" type="file" name="billscopy" accept="image/*" capture="camera" data-name="full-name" required>
                <div class="separator-fields"></div></center>
              </div>--->
                <center><button type="submit" class="btn btn-info" name="upload">Upload
      <span class="glyphicon glyphicon-upload"></span>
    </button></center>
            </form>
<!--========================Fetch All bills data======================------------------------->


			<br><br>
			<h3 style="text-align:center; ">My Bills</h3>
<!-------------------===================Start dynamice table grid ===============================================----------->
<?php


// SQL query to interact with info from our database
//$sql = mysql_query("SELECT * FROM mybills where user_email='$userEmail'"); 
//$i = 0;
// Establish the output variable
//$dyn_table = '<center><table  cellpadding="10">';
//while($row = mysql_fetch_array($sql)){ 
    
    //$id = $row["biils_id"];
    //$bills_file = $row["bills_copy"];
    
    //if ($i % 3 == 0) { // if $i is divisible by our target number (in this case "3")
      //  $dyn_table .= '<tr><td>' .'<img src=mybills/'. $bills_file .' width=100 height=50>'. '</td>';
   // } else {
        //$dyn_table .= '<td>' .'<img src=mybills/'. $bills_file .' width=100 height=50>'. '</td>';
    //}
   // $i++;
//}
//$dyn_table .= '</tr></table></center>';
?>


<?php// echo $dyn_table; ?>

<!----==============================End Table grid ===============================================--------------->
		

		<?php 
		$sql = mysql_query("SELECT * FROM mybills where user_email='$userEmail'"); 
		while($row = mysql_fetch_array($sql)){ 
		$product_id=$row[5];
		
		
		?>
			<center><table>
			<tr>
			<td><img src='mybills/<?php echo $row[7];?>' width=100 height=100 class="img-thumbnail" style="margin-left:50px;"><a href="delete_bills.php?bills=<?php  echo $row[0];?>"><span class="glyphicon glyphicon-remove" 
			style="position: relative;
    top:-20px;
    display: inline-block;
    font-family: 'Glyphicons Halflings';
    font-style: normal;
    font-weight: 400;
    line-height: 1;
    -webkit-font-smoothing: antialiased; color:black;"></span></a>
			
			
			<a href="add_desc.php?bills=<?php echo $row[0];?>"><span class="glyphicon glyphicon-pencil" style="position: relative;
    top: 30px;
	right:15px;
    display: inline-block;
    font-family: 'Glyphicons Halflings';
    font-style: normal;
    font-weight: 400;
    line-height: 1;
    -webkit-font-smoothing: antialiased; color:black;" data-toggle="modal" data-target="#myModal"></span></a>
  <?php
  $Query=mysql_query("Select * From product where product_id='$product_id'");
  while($row1 = mysql_fetch_array($Query)){ 
  $product_name=$row1[2];
  }
  ?>
  
<p style="text-align:center;"><?php echo $product_name;?>&nbsp;Model no&nbsp;<?php echo $row[6];?></p>
<!--------------======================== Close Description popup box==========================----------> 
			</td><tr><br>
		<?php } ?>
		
		

		</table></center><!-------=================== Table Close==========================---------->
		
	
 <br> <br> <br> <br> 
      <div class="w-tab-content tabs-content">
            <div class="w-tab-pane w--tab-active w-clearfix tab-pane" data-w-tab="Tab 1">
			  <center> <div class="group-block last" style="margin-top:20px; margin-left:60px">
                <a class="w-inline-block" href="product.php" data-load="1" style="text-decoration:none;">
                 
           
                    <div class="title-text" style="padding:-25px -25px; color:#FFF; background:#4fd2c2; text-align:center;width:200px;height:50px">Add Product</div>
                 
                </a>
              </div></center>
              
            </div>
            
          </div>
      </div>
       </div>
      </div>
    </div>
	
    <div class="page-content loading-mask" id="new-stack">
      <div class="loading-icon">
        <div class="navbar-button-icon icon ion-load-d"></div>
      </div>
    </div>
    <div class="shadow-layer"></div>
  </section>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script type="text/javascript" src="js/framework.js"></script>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  <!--[if lte IE 9]><script src="js/placeholders.min.js"></script><![endif]-->
</body>
</html>

当我在本网站的帐户中登录时,我的每个页面都显示此类型错误,并点击此类型错误显示的任何页面链接。我在登录后和注册后每页都使用相同的会话代码

  

这是我的登录代码

<?php
session_start();
?>
<!DOCTYPE html>

<html>
<head>
  <meta charset="utf-8">
  <title>Login</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  
  <link rel="stylesheet" type="text/css" href="css/normalize.css">
  <link rel="stylesheet" type="text/css" href="css/framework.css">
  <link rel="stylesheet" type="text/css" href="css/washington.css">
  <script src="js/webfont.js"></script>
  <script>
    WebFont.load({
      google: {
        families: ["Montserrat:400,700"]
      }
    });
  </script>
  <script type="text/javascript" src="js/modernizr.js"></script>
  <link rel="shortcut icon" type="image/x-icon" href="images/logoStandford32.ico">
  <link rel="apple-touch-icon" href="images/logoStandford32.ico">
 <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/ionicons.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
  <section class="w-section mobile-wrapper">

    <div class="page-content" id="main-stack" data-scroll="0">
      <div class="w-nav navbar"></div>
      <div class="body padding">
        <div class="logo-login"></div>
        <div class="bottom-section padding">
          <div class="w-form">
		  
<?php

include('dbConfig.php');
 

if(isset($_POST['login']))
{ 
    
    $user=$_POST['email'];
    $pass=$_POST['password']; 
  
	 $fetch=mysql_query("SELECT * FROM `user` WHERE user_email='$user' and user_pass='$pass'   ");
     $count=mysql_num_rows($fetch);
	 $fetch1 = mysql_fetch_array($fetch);
    if($count!="")
    {  

     $_SESSION['userEmailid']=$fetch1['user_email']; 			 	 	  	 	
       //header("Location:admin/index.php"); 
    echo '<meta http-equiv="refresh" content="0;URL=dashbord.php">';
    }
else
{
	
	  echo "<div class='alert alert-danger'>Email and Password is Wrong</div>";
 
}	
		
	 
}	
  
  
 
 ?>
 
            <form  method="post"  enctype="multipart/form-data" action="#">
              <div>
                <label class="label-form" for="email-field">USERNAME</label>
                <input class="w-input input-form" id="email-field" type="email" name="email" data-name="email" required="required">
                <div class="separator-fields"></div>
              </div>
              <div>
                <label class="label-form" for="email">PASSWORD</label>
                <div class="w-clearfix block-input-combined">
                  <input class="w-input input-form left" id="password-field" type="password" name="password" data-name="password" required="required"><a class="right-input-link" href="forgetPassword.php" data-load="1">Forgot Password</a>
                </div>
                <div class="separator-button-input"></div>
              </div>
              <input class="w-button action-button" type="submit" name="login" value="Sign In" data-wait="Please wait...">
              <div class="separator-button"></div><a class="link-upper" href="signup.php" data-load="1">YOU DON’T HAVE AN ACCOUNT? <strong class="b-link">SIGN UP</strong></a>
            </form>
            <div class="w-form-done">
              <p>Thank you! Your submission has been received!</p>
            </div>
            <div class="w-form-fail">
              <p>Oops! Something went wrong while submitting the form</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="page-content loading-mask" id="new-stack">
      <div class="loading-icon">
        <div class="navbar-button-icon icon ion-load-d"></div>
      </div>
    </div>
    <div class="shadow-layer"></div>
  </section>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script type="text/javascript" src="js/framework.js"></script>
  <!--[if lte IE 9]><script src="js/placeholders.min.js"></script><![endif]-->
</body>
</html>

  

这是我的注册码

<!DOCTYPE html>

<html>
<head>
  <meta charset="utf-8">
  <title>Sign Up</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  
  <link rel="stylesheet" type="text/css" href="css/normalize.css">
  <link rel="stylesheet" type="text/css" href="css/framework.css">
  <link rel="stylesheet" type="text/css" href="css/washington.css">

  <script src="js/webfont.js"></script>
  <script>
    WebFont.load({
      google: {
        families: ["Montserrat:400,700"]
      }
    });
  </script>
  <script type="text/javascript" src="js/modernizr.js"></script>
  <link rel="shortcut icon" type="image/x-icon" href="images/logoStandford32.ico">
  <link rel="apple-touch-icon" href="images/logoStandford32.ico">

  <link href="css/ionicons.min.css" rel="stylesheet" type="text/css" />
</head>

<body>
  <section class="w-section mobile-wrapper">

    <div class="page-content" id="main-stack" data-scroll="0">
      <div class="w-nav navbar" data-collapse="all" data-animation="over-left" data-duration="400" data-contain="1" data-easing="ease-out-quint" data-no-scroll="1">
        <div class="w-container">
          <div class="wrapper-mask" data-ix="menu-mask"></div>
          <div class="navbar-title">Sign Up</div>
          <a class="w-inline-block navbar-button" href="main_login.php" data-load="1">
            <div class="navbar-button-icon icon ion-ios-close-empty"></div>
          </a>
        </div>
      </div>
      <div class="body padding">
        <div class="logo-login smaller"></div>
        <div class="bottom-section padding">
          <div class="w-form">

		  <?php
include('dbConfig.php');
 

?>
<?php
 if(isset($_POST['submit']))
{ 
$user_name = $_POST['userName'];
$user_mobile = $_POST['userMobile'];
$user_email = $_POST['emailid'];
$user_pass = $_POST['pass'];


if($user_email !="")
{
 
$rs=mysql_query("select * from user where user_email='$user_email'");
if (mysql_num_rows($rs)>0)
{
	echo "<div class='alert alert-danger'>User is Already Exists</div>";
	exit;
} 
else
{
$sql=mysql_query("insert into user(user_name,user_mobile,user_email,user_pass) values ('$user_name','$user_mobile','$user_email','$user_pass')") or die(mysql_error());

session_start();
			$_SESSION['userEmailid']=$user_email;
			

if($sql){
	$msg="Name: ".$_POST['userName']."<br/> Email: ".$_POST['emailid']."<br/> Mobile No: ".$_POST['userMobile']."<br/> Password: ".$_POST['pass'];
	$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

	$mailresult=mail($user_email,'MeraApp Registration form',$msg,$headers);
	
	
echo"<script type='text/javascript'>
  window.location.href='language.php';
</script>";
}
}

}
 


}

?>
            <form method="post"  enctype="multipart/form-data" action="#">
              <div>
                <label class="label-form" for="full-name-field">FULL NAME</label>
                <input class="w-input input-form" id="full-name-field" type="text" name="userName" data-name="full-name" required="required">
                <div class="separator-fields"></div>
              </div>
			    <div>
                <label class="label-form" for="full-name-field">MOBILE NO.</label>
                <input class="w-input input-form" id="full-name-field" type="number" name="userMobile" data-name="full-name" required="required">
                <div class="separator-fields"></div>
              </div>
              <div>
                <label class="label-form" for="email-field">EMAIL</label>
                <input class="w-input input-form" id="email-field" type="email" name="emailid" data-name="email" required="required">
                <div class="separator-fields"></div>
              </div>
              <div>
                <label class="label-form" for="password-ield">PASSWORD</label>
                <input class="w-input input-form" id="password-ield" type="password" name="pass" data-name="password" required="required">
                <div class="separator-fields"></div>
              </div>
             
		
              <div class="separator-button-input"></div>
              <input class="w-button action-button" type="submit" name="submit" value="Sign Up"  class="fa fa-paper-plane" aria-hidden="true"data-wait="Please wait...">
              <div class="separator-button"></div><a class="link-upper" href="main_login.php" data-load="1">ALREADY HAVE AN ACCOUNT? <strong class="b-link">SIGN IN</strong></a>
            </form>
            <div class="w-form-done">
              <p>Thank you! Your submission has been received!</p>
            </div>
            <div class="w-form-fail">
              <p>Oops! Something went wrong while submitting the form</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="page-content loading-mask" id="new-stack">
      <div class="loading-icon">
        <div class="navbar-button-icon icon ion-load-d"></div>
      </div>
    </div>
    <div class="shadow-layer"></div>
  </section>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script type="text/javascript" src="js/framework.js"></script>
  <!--[if lte IE 9]><script src="js/placeholders.min.js"></script><![endif]-->
</body>
</html>

同样的错误是我的每一页,但相同的代码正确地在localhost上工作。 请帮帮我解决这个问题。

3 个答案:

答案 0 :(得分:0)

删除php标记之前和之后的空格。

在会话开始前,在页面顶部写下error_reporting(0);

答案 1 :(得分:0)

您可能需要为会话

执行一些操作
  • 从您开始<?php session_start();
  • 的顶部删除空白区域
  • 如果您将db_config.php包含在所有其他文件中,而不是顶部该文件中的启动会话。

看这里你可以这样做

假设:您正在其他所有文件中使用include('dbConfig.php');

所以这样做

<强> dbConfig.php

<?php
session_start();

//Your database connection strings or other code

从包含此文件的文件中删除session_start()

喜欢此文件myBills.php和其他文件。

答案 2 :(得分:0)

这可能只是因为

而发生
  • 您正在发送已发送的标题信息
  • 可能会在页面中启动会话两次或多次。

尝试这样做

ob_clean

它做什么?

  

此函数丢弃输出缓冲区的内容。