Include something with the URL?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
1985
Forum Newbie
Posts: 2
Joined: Sun Feb 22, 2004 4:51 pm

Include something with the URL?

Post by 1985 »

Weee! My first post!

Take a look at this JavaScript...

<script>
function init()
{
var e = document.getElementById("image");
if (e) e.src = location.hash.substr(1);
}
</script>
</HEAD>
<BODY onload="init();">
<IMG SRC="" id=image>

What image to be shown on the html site is the file you type in the url (document.html#picture.jpg).

Now for the question. How to do if I want a html document instead of an image? Who can make a php script that does that or is there a script for that already?
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

hmm, you mean this?

Code: Select all

<?php
$file = $_GET['file'];
include($file);
?>
example..
http://www.yoursite.com/index.php?file=main.html
1985
Forum Newbie
Posts: 2
Joined: Sun Feb 22, 2004 4:51 pm

Post by 1985 »

Yeah, thanks!

I thought it would take a half page of script to do that... you learn something new every day :) Thanks again!
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

its good to validate the input, check that the user dont put ".." in the file variable in the url...
Post Reply