Question: This is my index file:

```
session_start();
include_once 'conn.php';
if(isset($_SESSION['hell'])!="")
{
    header("Location: home.php");
}

if(isset($_POST['Login']))
{
    $email = $_POST['email'];
    $pass = $_POST['pass'];
    $res=mysql_query("SELECT * FROM studentreg WHERE email='$email'");
    $row=mysql_fetch_array($res);

    if($row['password']==$pass)
    {
        $_SESSION['hell']=$row['stu_id'];
        header("Location: home.php");
    }
    else
    {
        echo "hello"."<br/>";
        echo $row['password']."<br/>";
        echo $row['qualification'];
    }
}

```

This is my home file:

```
session_start();
include_once 'conn.php';

if(!isset($_SESSION['hell']))
{
    header("Location: index.php");
}

$res=mysql_query("SELECT * FROM studentreg WHERE stu_id = ".$_SESSION['hell']);
$sturow=mysql_fetch_array($res);
echo "welcome";

```

It will not work rather my query is working …why?

Answer: 
You add this line at start the page

```
ob_start(); 

```

and you add the this code after header function 

```
exit;

```
Try this code:

```
echo "<script>window.location='home.php'</script>";

```