Page 1 of 1

Include something with the URL?

Posted: Sun Feb 22, 2004 4:51 pm
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?

Posted: Sun Feb 22, 2004 5:31 pm
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

Posted: Mon Feb 23, 2004 4:32 pm
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!

Posted: Tue Feb 24, 2004 10:31 am
by AVATAr
its good to validate the input, check that the user dont put ".." in the file variable in the url...