HELP! Undefined index:

Hi folks,

I am both newly registered and new to PHP and have been staring blankly :frowning: at my page as I have come across the following error ‘Notice: Undefined index: page in C:\xampp\htdocs\phpTest\index.php on line 6’ with this piece of code below:

<?php

include (“includes/header.html”);

$page = $_GET[‘page’];

if ($page == ‘home’){
include (“includes/navhome.html”);
include(“includes/home.html”);

}elseif ($page == ‘links’){
include (“includes/navbar.html”);
include(“includes/links.html”);

}else{
include (“includes/navhome.html”);
include(“includes/home.html”);

}include(“includes/latest.html”);
include(“includes/footer.html”);

?>

Firstly welcome to to the forums and wonderful world that is php coding. This isn’t a serious error I’ve got 2 options for ya… turn off ‘notice settings’ in your php settings file or
change to:
[php]<?php

include (“includes/header.html”);

if (isset($_GET[‘page’])) {
$page = $_GET[‘page’];
}

if ($page == ‘home’){[/php]

As a last note are you recieving any other problems with the code or is it just the notice?

Also, make sure your field name “page” is in your form that calls this PHP page.

Sponsor our Newsletter | Privacy Policy | Terms of Service