the_dark_one02
07-21-2003, 10:09 PM
Is it posible to:::
have an include on a page:
<?php include("news.php"); ?>
then have a link change the source of the include to::
<?php include("downloads.php"); ?>
im new to php so i dont hav a clue :S
thanks for any help.
christiandude03
07-22-2003, 12:25 AM
There are a number of ways you can do this. One of the more secure ways, is to throw a page identifier in the query string and then select your page to include based on that...
index.php?include=news.php
index.php?include=download.php
-----------------
<?
$validFiles = array("news.php","download.php");
if ( in_array( $_GET['include'], $validFiles ) {
include_once( $_GET['include'] );
}
?>
-----------------
If you want other pages, add the following between download.php" and );
-----------------
,"filename"
-----------------
example:
-----------------
$validFiles = array("news.php","download.php","aboutme.php");
-----------------
the_dark_one02
07-22-2003, 10:26 AM
Ok thanks, ill hav a go to see if it works,
thanks again!
christiandude03
07-22-2003, 03:31 PM
Sounds like a plan...let me know how it works!
the_dark_one02
07-22-2003, 08:02 PM
nope, it comes up with this:
Parse error: parse error in /data/members/free/tripod/uk/c/h/a/chaosrealm/htdocs/layout.v2.php on line 53
which happens to be :
if ( in_array( $_GET['include'], $validFiles ) {
christiandude03
07-22-2003, 08:26 PM
Oops...sorry I forgot a ):
should be...
if ( in_array( $_GET['include'], $validFiles ) ) {
the_dark_one02
07-22-2003, 08:53 PM
hey thanks, one question, how do i get it to show news.php first?
coz its blank wen u first go on it
the_dark_one02
07-22-2003, 09:09 PM
AHA ive just had a brainwave,
if i put this it works :
<meta http-equiv="refresh" content="0;URL=layout.v2.php?include=news.php">
HOWEVER it refreshes every second
toosweet4u
07-23-2003, 01:03 AM
if (!isset($_GET['include'])) {
$_GET['include'] = 'news';
}
christiandude03
07-23-2003, 03:26 PM
Before $validFiles = array("news.php","download.php");
And actually, you need to put
if ( !isset( $_GET['include'] ) ) {
$_GET['include'] = "news.php";
}
the_dark_one02
07-23-2003, 10:09 PM
hey thanks, it worked,
thanks again
christiandude03
07-24-2003, 06:34 AM
Great! Glad I could help ya out!