Jump to content

Headers already sent


truenitin

headers already sent  

1 member has voted

  1. 1. headers already sent

    • 1
      1
    • 2
      0


Recommended Posts

Notice: Undefined variable: p in c:\program files\easyphp1-8\www\index.php on line 11

Notice: Undefined variable: p in c:\program files\easyphp1-8\www\index.php on line 19

Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\index.php:11) in c:\program files\easyphp1-8\www\index.php on line 23

I am getting this error when i run the following code.

<?php

if (isset($_GET['page']) and $_GET['page'] != "") {
$p = $_GET['page'];
}
if (strpos($p,"..")) {
    die("Bad page request");
}

if (!$p) $p = "main";
$content_file=$_SERVER["DOCUMENT_ROOT"]."/".$p.".php";
if (!file_exists($content_file)) {
    header("Location: {$_SERVER["PHP_SELF"]}");
    exit();
}

$title = ($p) ? "$p - My Site!" : "Main page - My Site!";
include("header.php");
include($content_file);
include("footer.php");
?>

i get this error when i use session_register also.

A possible solution?

Nitin
Link to comment
Share on other sites

Try this instead:
[code=php:0]if (isset($_GET['page']) and $_GET['page'] != "")
{
    $p = $_GET['page'];
}
else
{
    $p = "main";
}

if (strpos($p, ".."))
{
        die("Bad page request");
}

$content_file = $_SERVER["DOCUMENT_ROOT"] . "/" . $p . ".php";

if (!file_exists($content_file))
{
    header("Location: {$_SERVER['PHP_SELF']}");
    exit();
}

$title = ($p) ? "$p - My Site!" : "Main page - My Site!";

include("header.php");
include($content_file);
include("footer.php");[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.