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>
Member Avatar for rajarajan2017
$page = $_GET['page'];

I think this is your main file, then where do you get the page element from?

Member Avatar for rajarajan2017

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.

Member Avatar for rajarajan2017

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.