Current location: Hot Scripts Forums » Programming Languages » PHP » load a file within a webpage with a link


load a file within a webpage with a link

Reply
  #1 (permalink)  
Old 06-23-04, 11:58 PM
digitalf digitalf is offline
New Member
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
load a file within a webpage with a link

hey guys!

I am trying to stay away from frames for warious reason, and I have been recommended using php with id ->

<html>
<head>
</head>
<body>
<a href="index.php?id=newz">newz</a>

<div style="width=464;height=11;top=95;left=240;positio n:absolute;">
<?php
//We include the page file which is located in the Site directory
$fn = "" . $_GET['id'] . ".htm"; if (file_exists($fn)) {include($fn);} else {include("404.htm");}
?>
</div>
</body>
<html>

I have 2 problems when I call the script with a link <a href="index.php?id=newz">newz</a> which means load the file newz.htm in the place where div specifies it loads newz.htm befind the current content of the webpage and I need it to be on top of it or that the old content would not show up and the 404.htm page allways shows up and I need it to show up only whe "id" cannot find the file.
here is my webpage
http://www.pb.exocrew.com/digitalf/web/index.php
and try to use it with an id and see what happends
http://www.pb.exocrew.com/digitalf/w...x.php?id=index
http://www.pb.exocrew.com/digitalf/w...p?id=downloads


Thx...
Reply With Quote
  #2 (permalink)  
Old 06-24-04, 12:12 AM
sufyan sufyan is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Melbourne, AU
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Hi, I seem to get the same page no matter what I put after id=

http://www.pb.exocrew.com/digitalf/w...p?id=downloads is the same as http://www.pb.exocrew.com/digitalf/web/index.php

This is on IE, it doesn't render correctly in Mozilla
Reply With Quote
  #3 (permalink)  
Old 06-24-04, 01:18 PM
digitalf digitalf is offline
New Member
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by sufyan
Hi, I seem to get the same page no matter what I put after id=

http://www.pb.exocrew.com/digitalf/w...p?id=downloads is the same as http://www.pb.exocrew.com/digitalf/web/index.php

This is on IE, it doesn't render correctly in Mozilla
the one that ends with ?id=downloads is loading behind the content, the one that you should look at is http://www.pb.exocrew.com/digitalf/web/index.php and compare it with http://www.pb.exocrew.com/digitalf/w...x.php?id=index you should see the difference, the new layer should be on top but it is on the bottom, I need to make the new layer to show up on top of the old layer and not show up the layer below it.
Reply With Quote
  #4 (permalink)  
Old 06-24-04, 04:41 PM
php~pro php~pro is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: In a nice house.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Try specifying a 'z-index:' for the layer. z-indexes are stacking order from front to back. Search google for a tutorial on css.
Reply With Quote
  #5 (permalink)  
Old 06-24-04, 04:51 PM
hack adept hack adept is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
<html>
<head>
</head>
<body>
<a href="index.php?id=newz">newz</a>

<div style="width=464;height=11;top=95;left=240;position:absol ute;">
<?php
//We include the page file which is located in the Site directory
$id = "" . $_GET['id'] . ".htm"; if (file_exists($id)) {include($id);} else {include("404.htm");}
?>
</div>
</body>
<html>
Try that, and linking the same way.

$_GET['id'] wasn't working, because the variable you set was $fn, not $id, so therefore it returns false.
Reply With Quote
  #6 (permalink)  
Old 06-24-04, 09:11 PM
digitalf digitalf is offline
New Member
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by hack adept
Code:
<html>
<head>
</head>
<body>
<a href="index.php?id=newz">newz</a>

<div style="width=464;height=11;top=95;left=240;position:absol ute;">
<?php
//We include the page file which is located in the Site directory
$id = "" . $_GET['id'] . ".htm"; if (file_exists($id)) {include($id);} else {include("404.htm");}
?>
</div>
</body>
<html>
Try that, and linking the same way.

$_GET['id'] wasn't working, because the variable you set was $fn, not $id, so therefore it returns false.
Still aint working the new layer is still being loaded behind an old layer, here is an example http://www.pb.exocrew.com/digitalf/w...x.php?id=index , what this does it is just loading the same page into it self.
Reply With Quote
  #7 (permalink)  
Old 06-25-04, 04:01 AM
sufyan sufyan is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Melbourne, AU
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Ok... have a look at:

Index page (index.htm)
http://67.19.4.33/pt/digitalf/index.php?id=index
Download Page (download.htm)
http://67.19.4.33/pt/digitalf/index.php?id=download
Test 404 error:
http://67.19.4.33/pt/digitalf/index....slkjfhskdjhfsf

If that's what you're trying to do, keep reading, if not stop here...

Source for index.php:

PHP Code:

<html>

<head>
<meta name="description" content="Calgary and Montreal Hangout For Gamers!" />
<meta name="keywords" content="DigitalFiles,DigitalFiles.tk,DigitalFiles.da.ru" />
<meta name="copyright" content="Copyright  2004 DigitalFiles ALL RIGHTS RESERVED" />
<title>Welcome to DigitalFiles.Da.Ru</title>
<style type="text/css">
<!--

a:link {
color : #ffff00;
text-decoration : underline;
}
a:active {
color : #ffff00;
text-decoration : underline;
}
a:visited {
color : #ffff00;
text-decoration : underline;
}
a:hover {
color : #990000;
text-decoration : underline;
}
h5 {
color : #ffff00;
text-align : center;
}
h4 {
color : #ffff00;
text-align : center;
}
body {
background-image : url(./images/whole.jpg);
background-repeat : no-repeat;
background-color : #000000;
margin-top : 0;
margin-left : 0;
}
.body-text {
color : #c0c0c0;
font-size : 10pt;
background : url(images/background1.jpg);
background-repeat: no-repeat;
}

-->
</style>
<script type="text/javascript" src="./scripts/music.js"></script>
</head>
<body>


<!-- Links -->

<div style="width=210;height=25;top=180;left=29;position:absolute;"><a href="./index.htm"><img src="./images/newz.jpg" border="0" alt="" /></a></div>
<div style="width=210;height=25;top=205;left=29;position:absolute;"><a href="../"><img src="./images/forum.jpg" border="0" alt="" /></a></div>
<div style="width=210;height=30;top=235;left=29;position:absolute;"><a href="index.php?id=downloads"><img src="./images/downloads.jpg" alt="" border="0" /></a></div>
<div style="width=210;height=30;top=265;left=29;position:absolute;"><img src="./images/mirc.jpg" alt="" /></div>
<div style="width=210;height=24;top=295;left=29;position:absolute;"><img src="./images/torrents.jpg" alt="" /></div>
<div style="width=210;height=25;top=319;left=29;position:absolute;"><img src="./images/links.jpg" alt="" /></div>
<div style="width=210;height=25;top=349;left=14;position:absolute;"><img src="./images/music.jpg" alt="" /></div>
<div style="width=210;height=25;top=378;left=29;position:absolute;"><script type="text/javascript">music();</script></div>

<!-- Server Status example <img src="http://digitalf.togetherhost.com/status/status.php?link=www.digitalf.togetherhost.com" border="3"  />-->

<!-- Body Info -->

<div style="width=464;height=11;top=95;left=240;position:absolute;" class="body-text">
<?php
//We include the page file which is located in the Site directory
$fn "" $_GET['id'] . ".htm";
if (
file_exists($fn))
{
    include(
$fn);
}
else
{
    include(
"404.htm");
}
?>
</div></body></html>
As for index.htm, download.htm, 404.htm, you just need to create pages which will be included in your index.php file. Since your index.php already has a navigation bar, you do not need to have a navigation bar in these pages.

Example of index.htm:

Code:
<img src="images/hr.gif" alt="" />
<br />

<h4>Welcome to DigitalFiles.Da.Ru</h4>

May 23,2004 <a href="mailto:grunt_g_@hotmail.com?subject=DigitalFiles">Dark&nbsp;&nbsp;Sniper&nbsp;&nbsp;</a><br />
<div style="left=5;position:relative;">
Updated the forum.
</div><br />

May 20,2004 <a href="mailto:grunt_g_@hotmail.com?subject=DigitalFiles">Dark&nbsp;&nbsp;Sniper&nbsp;&nbsp;</a><br />
<div style="left=5;position:relative;">
Second part of news!<br />Finally found out a way to validate as XHTML and keep my JavaScript code. Orgenized the code a bit, so it would
easier to modify or add more code.
</div><br />

May 20,2004 <a href="mailto:grunt_g_@hotmail.com?subject=DigitalFiles">Dark&nbsp;&nbsp;Sniper&nbsp;&nbsp;</a><br />
<div style="left=5;position:relative;">
Changed the random script file to use objects instead of using embed, validated both
CSS and the webpage as XHTML 1.0. Still have one object javascript error which is
not compatible with XHTML 1.0 but I have no idea how to fix it, since
<a href="http://validator.w3.org" target="_blank">http://validator.w3.org</a> doesnt like neither embed and neither object in javascript.
<a href="mailto:Dark_energy_@hotmail.com?subject=DigitalFiles">Dark&nbsp;&nbsp;Energy&nbsp;&nbsp;</a> is working on the logo for the webiste.
</div><br />

May 19,2004 <a href="mailto:grunt_g_@hotmail.com?subject=DigitalFiles">Dark&nbsp;&nbsp;Sniper&nbsp;&nbsp;</a><br />
<div style="left=5;position:relative;">
Fixed few bugs that we have on the webpage, improoved page loading, added
random music script, fixed few links, added and <a href="./dl/index.php?nu.mp3">testing</a> out new php scripts.
</div><br />

May 13,2004 <a href="mailto:grunt_g_@hotmail.com?subject=DigitalFiles">Dark&nbsp;&nbsp;Sniper&nbsp;&nbsp;</a><br />
<div style="left=5;position:relative;">
We have moved onto a different server.
</div><br />
<img src="images/hr.gif" alt="" />
The source for the sample download page was simply:

Code:
Here... a page where you can d/l stuff...
Hope this helps...
Reply With Quote
  #8 (permalink)  
Old 06-25-04, 09:08 PM
digitalf digitalf is offline
New Member
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Reply With Quote
  #9 (permalink)  
Old 06-25-04, 10:49 PM
sufyan sufyan is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Melbourne, AU
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Glad to hear that
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting the created file (fopen/fwrite) Programme PHP 5 02-14-04 03:09 PM
How to write a php script to load a text file into a table automatically? xmxpcom PHP 2 02-12-04 08:37 AM
Please I Need help before all my hair is gone! LisatheNovice Perl 6 11-22-03 03:05 PM
Create a next page link when there are too many records to be display in a webpage Han84 ASP 0 10-19-03 10:32 PM
text file to link rush989 Script Requests 3 08-29-03 06:12 PM


All times are GMT -5. The time now is 05:06 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.