At 8/4/04 08:59 AM, Flash_Gordon wrote:
http://www.yourdomainhere.com/iframe.php?=home
You left out the variable name, it would be ".../iframe.php?var=home".
Don't forget that the argument to include is relative to the directory where the script is located (in this case iframe.php). So if you have your PHP scripts in /cgi-bin on the webserver, it might be in an aliased folder or something, you might want to check that. And /cgi-bin on the webserver would probably be something like /var/www/htdocs/cgi-bin on the actual computer, rather than through Apache.
<?php
include("folder/" . $page . ".php");
?>
So the correct way to do this (using my ?var=home) would be something like:
<?php
$page = $_GET['var'];
// $_GET is the parsed arguments to the URL
include("/var/www/htdocs/myfolder/$page.php") or die("Error: incorrect argument.");
/* You don't have to . concatenate variables inside double quotes, and the "or die" part ensures that if they enter a bad filename they will only see the error message (and whatever output was before that). The flaw in this design is that if people put ?var=../../../../../../etc/passwd or something like that (URLencoded, of course), they could for instance retrieve your passwd file and attempt to brute force any accounts on your computer. But that isn't too hard to disable on the serverside. */
?>