php - Message: session_start(): Cannot send session cache limiter - headers already sent -
this question has answer here:
- how fix “headers sent” error in php 11 answers
having problem sessions becoming annoying. every time try start session on particular page following error:
warning: session_start(): cannot send session cache limiter - headers sent (output started @ /home/uplbcdcn/public_html/cdc/admin_uplbcdc/header.php:57) in /home/uplbcdcn/public_html/cdc/admin_uplbcdc/index.php on line 33
warning: cannot modify header information - headers sent (output started @ /home/uplbcdcn/public_html/cdc/admin_uplbcdc/header.php:57) in /home/uplbcdcn/public_html/cdc/admin_uplbcdc/index.php on line 42
here code: header.php
<!doctype html> <html> <head> <title>uplb credit , 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 div { top: 0px; left: -100%; -webkit-transition: 0.3s ease; -moz-transition: 0.3s ease-in-out; -o-transition: 0.3s ease-in-out; -ms-transition: 0.3s ease-in-out; transition: 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 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> 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 * users username='$username' , 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') ?>
two things can try
1) write session_start() @ top.
2) use exit while using header
exit(header('location:dashboard.php'));
Comments
Post a Comment