Page 1 of 1
inserting php file into same page
Posted: Tue Nov 23, 2004 10:40 am
by spencermjax
I have an html page with a link
(<a href="?page=website" >Website Templates</a>) that I want to return info to another location on the same page. The following is the location of the data to be inserted.
(
<?PHP $file = $_GET["page"]; if (!isset($file)) { include"./website.php"; } else { include "$file.php"; } ?> )
Is there anything wrong with it? It does not seem to be working. The incomming data is in a .php file.
Thanks.
Posted: Tue Nov 23, 2004 10:45 am
by kanaps
If I anderstood all correct you can do following
$ling= "<a href=\"?page=website\" >Website Templates</a>";
//and you can paste this link as many times as you like and where you like it.
print $link;print $link;print $link;print $link;print $link;
Posted: Tue Nov 23, 2004 11:05 am
by spencermjax
Unfortunitely that did not seem to work. The link looked like this
$link= 'Website Templates';
Posted: Tue Nov 23, 2004 11:19 am
by kanaps
yes, but if you click on your link you will be sent to ?page=website if you need to be send to index.php, just change "?page=website" with "index.php"
Posted: Tue Nov 23, 2004 4:40 pm
by rehfeld
$file will ALWAYS be set, you defined it
do
if (isSet($_GET['file'])) {
include $GET['file'].'php';
}
be warned though, that is a security hole waiting to be exploited
try a search on this board for :
include security
and youll see why
Posted: Tue Nov 23, 2004 4:52 pm
by John Cartwright
Code: Select all
<?
function goto($page)
{
$acceptable = array('index','main','page4','page10');
if (in_array($page,$acceptable) && file_exists($page'.php'))
{
return $page'.php';
}
else
{
return 'denied.php';
}
}
include goto($_GET['page']);
?>
In a nutshell this is what I do to validate included pages
Posted: Wed Nov 24, 2004 2:03 pm
by spencermjax
I'm very new to this. In the above code will that function go in the <head> tags? If so what will the link code look like? and what will the code look like where I want the file to be inserted?
Posted: Fri Nov 26, 2004 6:51 am
by spencermjax
Thanks for the help. Problem resoled. I simply did not have my MIME types set on my sever. My orginal codewas just fine but thanks for the input anyway.