-2

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\needs\home.php:2) in C:\xampp\htdocs\needs\session.php on line 6

Session page:

    <?php
//Start session
session_start();
//Check whether the session variable SESS_MEMBER_ID is present or not
if (!isset($_SESSION['id']) || ($_SESSION['id'] =='')) {
    header("location: index.php");
    exit();
}
$session_id=$_SESSION['id'];
$user_query = $conn->query("select * from members where member_id = '$session_id'");
$user_row = $user_query->fetch();
$name = $user_row['firstname']." ".$user_row['middlename']." ".$user_row['lastname'];
?>
Mamun
  • 1
  • 3
  • 1
    First change the title. – Ullas Jul 14 '15 at 07:30
  • If this is a duplicate of the other question, then please delete this question, otherwise, change the title to something meaningful so that others can read the question title and understand in general what you are asking. – Guy Schalnat Jul 14 '15 at 07:36

5 Answers5

0

It's probably caused by the whitespace before opening PHP tag.

Kristian Vitozev
  • 5,791
  • 6
  • 36
  • 56
0

Please Check the Home.php page: Probable Problems are:

1.If something is echoed above header('location:XXXXX');

2.If you have some empty lines above header('location:XXXX');

Check it and Try Removing these things.

0

Try this, Removed white space before PHP tag

 <?php
    //Start session
    session_start();
    //Check whether the session variable SESS_MEMBER_ID is present or not
    if (!isset($_SESSION['id']) || ($_SESSION['id'] =='')) {
        header("location: /index.php");
        exit();
    }
    $session_id=$_SESSION['id'];
    $user_query = $conn->query("select * from members where member_id = '$session_id'");
    $user_row = $user_query->fetch();
    $name = $user_row['firstname']." ".$user_row['middlename']." ".$user_row['lastname'];
    ?>
Jpec
  • 300
  • 2
  • 14
0

if you are including this file in other file then make sure you don't echo anything or use ob_start() as first line of your code. Hope this will help.

Prashant
  • 126
  • 1
  • 8
0

Most probably the problem is due to the white spaces above your link. Try removing those white spaces

TOOR PIZZZ
  • 72
  • 1
  • 9