1,105,594 Community Members

PHP Help.

Member Avatar
stu9954
Newbie Poster
3 posts since Apr 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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>
Member Avatar
cwarn23
Occupation: Genius
3,028 posts since Sep 2007
Reputation Points: 387 [?]
Q&As Helped to Solve: 281 [?]
Skill Endorsements: 15 [?]
Team Colleague
Featured
 
0
 

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
rajarajan07
Nearly a Posting Virtuoso
1,448 posts since May 2008
Reputation Points: 123 [?]
Q&As Helped to Solve: 242 [?]
Skill Endorsements: 3 [?]
 
0
 
$page = $_GET['page'];

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

Member Avatar
rajarajan07
Nearly a Posting Virtuoso
1,448 posts since May 2008
Reputation Points: 123 [?]
Q&As Helped to Solve: 242 [?]
Skill Endorsements: 3 [?]
 
0
 

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
stu9954
Newbie Poster
3 posts since Apr 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks, but i'm afraid that it does not work. This is what im getting
[img]www.uploadmyshit.airsoftupdate.com/upload/6036untitled.JPG[/img]

Member Avatar
rajarajan07
Nearly a Posting Virtuoso
1,448 posts since May 2008
Reputation Points: 123 [?]
Q&As Helped to Solve: 242 [?]
Skill Endorsements: 3 [?]
 
0
 

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 test.php (1.41KB)
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article