Forum Moderators: coopster
Then for the main content <?php @ require_once ("$page.html";?>
then for the url index.php?page=about
Now the thing I was reading said this --->
<removed copy paste from other site - jatar_k>
What I really want to do is have a the content change on one index file so I do not have to copy php code throughout the website and it would seem that this would be one way to do it.
I guess I could just not be thinking in the right direction and well if anyone can point me in the right way that would be great
[edited by: jatar_k at 4:56 pm (utc) on Oct. 31, 2006]
index.php?page=about about.html, you'll need to grab the GET array variable "page" and then use it. Running PHP pre-v.4.2 made this easy, as
register_globals was enabled by default. PHP v.4.2+ disables register_globals (wisely) by default, so you need to access the array directly: $page=$_GET["page"]; <?php @ require_once ("$page.html";?> <?php @ require_once ("$page.html"[b])[/b];?> Should be all there is to it.
(It looks like the "@" sign is automagically grabbing the variables from the URI, although I can't find anything about it in the docs, so accessing the GET array may not be necessary ... in which case the missing paren should fix it up for ya.)
[edited by: StupidScript at 10:18 pm (utc) on Oct. 30, 2006]
$page=$_GET["page"];
$arr_allowed_pages = array("about", "history", "contact");
if(!in_array($page, $arr_allowed_pages)) $page = "error";
...
?>
<?php require_once ("$page.html");?>
Always validate input data, as it can be used to breach security.
Regards
Michal
When I use my link ---> url index.php?page=about.php
can i make a database variable as well
ie I use to link /about.php?REPORT_NAME=name
and it would look up only those field that equal name
Now I have tried to do it using
index.php?page=about.php?REPORT_NAME=name
but it does not work.
If i use
index.php?page=about.php
I will get all the reports but it is the 2nd? that does me in
I gett error --->
An error occurred in script index.php on line 138: main(about/about.php?REPORT_NAME=about): failed to open stream: No such file or directory
any help would be greatful
index.php?page=about.php&REPORT_NAME=name
Then as you parse data from about.php file, then all the variables are passed through:
about.php:
<?php
echo ". The name of the town is ".$_GET['view'];
?>
index.php:
<?php
echo $_GET['view'];
require_once('about.php');
?>
index.php?view=Alamakota will output:
Alamakota. Then name of the town is Alamakota
Hope this cleares things for you.
Michal