We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,703 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

PHP Help.

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>
3
Contributors
5
Replies
1 Day
Discussion Span
3 Years Ago
Last Updated
6
Views
stu9954
Newbie Poster
3 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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>
cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 261
Skill Endorsements: 13
$page = $_GET['page'];

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

rajarajan07
Nearly a Posting Virtuoso
1,450 posts since May 2008
Reputation Points: 167
Solved Threads: 241
Skill Endorsements: 1

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.

rajarajan07
Nearly a Posting Virtuoso
1,450 posts since May 2008
Reputation Points: 167
Solved Threads: 241
Skill Endorsements: 1

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

stu9954
Newbie Poster
3 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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)
rajarajan07
Nearly a Posting Virtuoso
1,450 posts since May 2008
Reputation Points: 167
Solved Threads: 241
Skill Endorsements: 1

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0976 seconds using 2.7MB