FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

PHP Coding

 


aznhomieboi1689
When I use this php code:

Code:

<?php
include($file . ".php");
?>


It doesn't work for linking pages: http://site.com/main.php?file=name

When I use the code in the page (template), it doesn't work when I use that link code....what's wrong?
m-productions
You may get faster and better help in the Php and MySQL Section, but ill try to help



Code:

$file = $_GET['file'];


you need to add that so that it gets the var from the adress bar.

Code:

<?php
$file = $_GET['file'];
include($file . ".php");
?>
aznhomieboi1689
Thanks!
Daniel15
That is incredibly insecure, and I suggest you edit the script so it has a list of allowed pages:

Code:

<?php
// All the valid pages.
$pages = array('index', 'about', 'contact');
// Doesn't exist?
if (!in_array($_GET['file'], $pages))
   // Kick them out
   die('Hey! That's not a valid page!');

// Load the page.
include($_GET['file'] . '.php');
?>
Related topics

Managing php pages
php coding needed
PHP Problem
how to make a php nav
Delphi IDE by CodeGear for PHP coding !!!

PHP Form Question
Using PHP in error pages
Using PHP code from a Database
Get alternate table color with php
PHP commands need help!

Frihost banner contest
Dynamic PHP Images
Forum
Using Key Words
Two links for one anchor?
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.