Start New Discussion within our Web Development Community

I have started to code a website with a simple PHP dynamic page.
I am getting a error message on the homepage "Notice: Undefined index: page in C:\w\www\index.php on line 26". However the page does come up underneath the error. Can some one please take a look at the code and tell me what is wrong
This is what ive got

<html>
<head><title>My Portfolio</head>
<body bgcolor='#f1f1f1' text='#000000' link='#33cc00' alink='#33cc00' vlink='#33cc00'>

<table align='center' width='95%' bgcolor='#FFFFFF' style='border-color:#999999;border-style:solid;border-width:1px' border=0>

<tr>
<td align='center'>
<table width='100%'>
<img src='images/logo.png'>
</td>
</tr>
</table>
</table>
<br>
<table align='center' width='95%' bgcolor='#FFFFFF' style='border-color:#999999;border-style:solid;border-width:1px' border=0>

<tr>
<td align='center'>
<table width='100%'>
<font size='2' face='arial'><a href ="home.php">Home</a> | <a href ="2.php">Blog</a> | <a href ="home.php">Projects</a> | <a href ="">Contact</a></font>
</td>
</tr>
<td align='center'> <font size='2' face='arial'>
<?php
$page = $_GET['page'];
if (!$page)

  $path = "inc/".$page.".php";
  if (file_exists($path))
include($path);

  else
  {
    echo "Sorry, This page does not exist, Please press the back button on your browser.";
  }
?>
</font>
</td>
</table>
</table>





</body>
</html>

Try this:

<html>
<head><title>My Portfolio</head>
<body bgcolor='#f1f1f1' text='#000000' link='#33cc00' alink='#33cc00' vlink='#33cc00'>

<table align='center' width='95%' bgcolor='#FFFFFF' style='border-color:#999999;border-style:solid;border-width:1px' border=0>

<tr>
<td align='center'>
<table width='100%'>
<img src='images/logo.png'>
</td>
</tr>
</table>
</table>
<br>
<table align='center' width='95%' bgcolor='#FFFFFF' style='border-color:#999999;border-style:solid;border-width:1px' border=0>

<tr>
<td align='center'>
<table width='100%'>
<font size='2' face='arial'><a href ="home.php">Home</a> | <a href ="2.php">Blog</a> | <a href ="home.php">Projects</a> | <a href ="">Contact</a></font>
</td>
</tr>
<td align='center'> <font size='2' face='arial'>
<?php
if (!isset($_GET['page'])) { $_GET['page']=''; }
$page = $_GET['page'];
if (!$page)

  $path = "inc/".$page.".php";
  if (file_exists($path))
include($path);

  else
  {
    echo "Sorry, This page does not exist, Please press the back button on your browser.";
  }
?>
</font>
</td>
</table>
</table>





</body>
</html>

Yeah, Cwarn identified the same and added a code to check whether it is already submitted or page is clear. So initially no page is there to fetch. the above cwarn code will work for you. Thanks Cwarn.

Please check whether you have a logo file in the image folder:
<img src='images/logo.png'>

And something you pasted or recreated some of the lines in the php. Double check it! I attached a file also please check with that and paste the code from there

Attachments
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>My Portfolio</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="language" content="en" />
	<meta name="description" content="" />
	<meta name="keywords" content="" />
</head>
<body bgcolor='#f1f1f1' text='#000000' link='#33cc00' alink='#33cc00' vlink='#33cc00'>

<table align='center' width='95%' bgcolor='#FFFFFF' style='border-color:#999999;border-style:solid;border-width:1px' border=0>

<tr>
<td align='center'>
<table width='100%'>
<img src='images/logo.png'>
</td>
</tr>
</table>
</table>
<br>
<table align='center' width='95%' bgcolor='#FFFFFF' style='border-color:#999999;border-style:solid;border-width:1px' border=0>

<tr>
<td align='center'>
<table width='100%'>
<font size='2' face='arial'><a href ="home.php">Home</a> | <a href ="2.php">Blog</a> | <a href ="home.php">Projects</a> | <a href ="">Contact</a></font>
</td>
</tr>
<td align='center'> <font size='2' face='arial'>
<?php
if (!isset($_GET['page'])) { $_GET['page']=''; }
$page = $_GET['page'];
if (!$page)

  $path = "inc/".$page.".php";
  if (file_exists($path))
include($path);

  else
  {
    echo "Sorry, This page does not exist, Please press the back button on your browser.";
  }
?>
</font>
</td>
</table>
</table>
</body>
</html>
This article has been dead for over six months. Start a new discussion instead.