PDA

View Full Version : displaying a page via a php include with a var....


sir pannels
12-29-2002, 03:37 AM
hmm hey there...
the subject there.. is this ok in php.. so like..

<?
$page = $view
?>

<? include ('$page.php'); ?>

and the $view is cuming from the url string... cuz it says "faile dto open $page.php" yadda yadda.
any ideas?
thanks :D

Nightfire
12-29-2002, 08:11 AM
Try $_GET['view'] or $HTTP_GET_VARS['view'] instead of $view

Also give include($page.'.php'); a try

Ökii
12-29-2002, 10:53 AM
for security, always hardcode part of the path to the file into the include call whenever you are using url passed page names.

include('pages/'.$_GET['page'].'.php');

stops people running external scripts and exploring your file system and files.

sir pannels
12-29-2002, 03:30 PM
ok cheers the both o fyou i`ll try it out now :)
P :thumbsup:

brothercake
12-29-2002, 04:30 PM
As I understand it, variables inside strings are only allowed if you use double quotes. so


include ("$page.php");


or


include ("path/$page.php");



should work