sender tomal " Cannot send session cache limiter - headers already sent".

0 votes
asked Oct 27, 2016 in Blogging by Hasan Mahadi (340 points)

/I use XAMPP for Windows Version 1.7.1 . I read lot's of post about that topic.
i already use header side <?php ob_start(); ?> and footer <?php ob_end_flush() ; ?> and also change my php.ini utput_buffering: = on
/
-----------------------------------------------------------------------------

index.php 


<?php ob_start();?>
<?php
include 'inc/header.php';
?>
<?php include 'inc/sidebar.php';?>
<div class="grid_10">
  <div class="box round first grid">
    <h2> Dashbord</h2>
    <div class="block"> Welcome admin panel </div>
  </div>
</div>
<?php include 'inc/footer.php';?>

-----------------------------------------------------------------------------
header.php

<?php ob_start(); ?>
<?php
include '../lib/session.php';
session::ckeckSession();
?>
<?php ob_start(); ?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Location" content="http://zsoft.com.bd/">
<title>Admin</title>
<link rel="stylesheet" type="text/css" href="css/reset.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/text.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/grid.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/layout.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/nav.css" media="screen" />
<link href="css/table/demo_page.css" rel="stylesheet" type="text/css" />
<!-- BEGIN: load jquery -->
<script src="js/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery-ui/jquery.ui.core.min.js"></script>
<script src="js/jquery-ui/jquery.ui.widget.min.js" type="text/javascript"></script>
<script src="js/jquery-ui/jquery.ui.accordion.min.js" type="text/javascript"></script>
<script src="js/jquery-ui/jquery.effects.core.min.js" type="text/javascript"></script>
<script src="js/jquery-ui/jquery.effects.slide.min.js" type="text/javascript"></script>
<script src="js/jquery-ui/jquery.ui.mouse.min.js" type="text/javascript"></script>
<script src="js/jquery-ui/jquery.ui.sortable.min.js" type="text/javascript"></script>
<script src="js/table/jquery.dataTables.min.js" type="text/javascript"></script>
<!-- END: load jquery -->
<script type="text/javascript" src="js/table/table.js"></script>
<script src="js/setup.js" type="text/javascript"></script>
<script type="text/javascript">
        $(document).ready(function () {
            setupLeftMenu();
            setSidebarHeight();
        });
    </script>
</head>
<body>
<div class="container_12">
<div class="grid_12 header-repeat">
  <div id="branding">
    <div class="floatleft logo"> <img src="img/livelogo.png" alt="Logo" /> </div>
    <div class="floatleft middle">
      <h1>Zsoft Admin Panel </h1>
      <p>www.zsoft.com.bd.com</p>
    </div>
    <div class="floatright">
      <div class="floatleft"> <img src="img/img-profile.jpg" alt="Profile Pic" /></div>

      <?php


        if(isset($_GET['action']) && $_GET['action'] == "logout")
        {
        session::destroy();
        }
        ?>
      <div class="floatleft marginleft10">
        <ul class="inline-ul floatleft">
          <li>Hello Admin</li>
          <li><a href="?action=logout">Logout</a></li>
        </ul>
      </div>
    </div>
    <div class="clear"> </div>
  </div>
</div>
<div class="clear"> </div>
<div class="grid_12">
  <ul class="nav main">
    <li class="ic-dashboard"><a href="index.php"><span>Dashboard</span></a> </li>
    <li class="ic-form-style"><a href=""><span>User Profile</span></a></li>
    <li class="ic-typography"><a href="changepassword.php"><span>Change Password</span></a></li>
    <li class="ic-grid-tables"><a href="inbox.php"><span>Inbox</span></a></li>
    <li class="ic-charts"><a href="postlist.php"><span>Visit Website</span></a></li>
  </ul>
</div>
<div class="clear"> </div>
<?php  ob_end_flush() ; ?>

-----------------------------------------------------------------------------
footer.php


<div class="clear">
        </div>
    </div>  
<div class="clear">
    </div>
    <div id="site_info">
        <p>
         © Copyright <a href="http://trainingwithliveproject.com">Training with live project</a>. All Rights Reserved.
        </p>
    </div>
</body>
</html>
<?php ob_end_flush() ; ?>

-----------------------------------------------------------------------------

session.php


<?php
class session{
    public static function init(){
    session_start();
    }

    public static function set ($key,$val)
    {
    $_SESSION['$key'] = $val;
    }

    public static function get ($key)
    {
    if(isset($_SESSION['$key']))
    {
    return $_SESSION['$key'];
    }
    else
    {
    return false;
    }
    }

    public static function ckeckSession()
    {
    self::init();
    if(self::get("login") == false)
    {
        self:: destroy();
        header("Location: login.php");      
        exit;

     }
    }


    public static function destroy()
    {
        session_destroy();  
        header("Location: login.php");
        exit;       

    }
}

login.php

<?php ob_start(); ?>
<?php
include '../lib/session.php';
session:: init();
?>
<?php include '../config/config.php';?>
<?php include '../lib/database.php';?>
<?php include '../helpers/format.php';?>
<?php $db = new Database();?>
<?php $fm = new format();?>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Login</title>
<link rel="stylesheet" type="text/css" href="css/stylelogin.css" media="screen" />
</head>
<body>
<div class="container">
<section id="content">
<?php 
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$username = $fm ->validation($_POST['username']);
$password = $fm ->validation(md5($_POST['password']));


$username = mysqli_real_escape_string($db->link,$username);
$password = mysqli_real_escape_string($db->link,$password);

$query = "SELECT * FROM  `tbl_user` WHERE   `username` = '$username' AND `password` = '$password' ";
$result = $db->select($query);
if($result != false)
{
$value = mysqli_fetch_array($result);
$row = mysqli_num_rows($result);
if($row > 0)
{                   

$ami = session::set("login", tomal );
session::set("username", $value['username']);
session::set("userid", $value['id']);

//echo $_SESSION["login"];
//echo $_SESSION["username"];
//echo $_SESSION["userid"];
//echo $value['id'];
/*die("<script>location.href = 'index.php'</script>");*/
header("Location: index.php");
exit;
}else{
                    echo "<snap style ='color : red; font-size:18px;'>No Result Found</snap>";
                    }
                    }else
                    {
                    echo "<snap style ='color: red ; font-size:18px;'>Username  or Password Not matched</snap>";
                    }
}
?>

    <form action="login.php" method="post">
      <h1>Admin Login</h1>
      <div>
        <input type="text" placeholder="Username" required="" name="username"/>
      </div>
      <div>
        <input type="password" placeholder="Password" required="" name="password"/>
      </div>
      <div>
        <input type="submit" value="Log in" />
      </div>
    </form>
    <!-- form -->
    <div class="button"> <a href="#">Training with live project</a> </div>
    <!-- button -->
  </section>
  <!-- content -->
</div>
<!-- container -->
</body>
</html>

1 Answer

0 votes
answered Oct 27, 2016 by Shumon (7,690 points)

Use XAMPP server latest Version (7.0.9 / PHP 7.0.9)

commented Oct 29, 2016 by Hasan Mahadi (340 points)

thanks bro its work

722 questions

656 answers

179 comments

4,717 users

Welcome to IDB Scholars Forum, where you can ask questions and receive answers from other members of the community. It's 100% free.
আইডিবি স্কলারস ফোরামে আপনাকে স্বাগত - প্রোগ্রামিং, ডিজাইন, ডেভেলপমেন্ট, ব্লগিং, ইন্টারনেটসহ তথ্য প্রযুক্তির যাবতীয় বিষয় নিয়ে আলোচনার একটি মুক্ত মঞ্চ হলো এই ফোরাম । এখানে আইসিটি বিষয়ক আপনার প্রশ্ন, উত্তর এবং অভিজ্ঞতা শেয়ার করুন, আলোচনা করুন এবং সমাধান নিন। দেশের তরুণ প্রজন্মকে আইসিটিতে আগ্রহী করাই আমাদের মূল লক্ষ্য।
** ইংলিশ বা বাংলা যে কোনো ভাষায় আপনি এই ফোরামে আলোচনা করতে পারবেন। তবে বাংলাকে ইংরেজি অক্ষরে লিখবেন না।
  1. tulbadex

    110 points

    0 answers

  2. mealbulb9

    100 points

    0 answers

  3. seat1temper

    100 points

    0 answers

  4. roll0fender

    100 points

    0 answers

  5. KeiraX382741

    100 points

    0 answers

...