Hi!
I want to know how to do CAR.PHP?PAGE=BUS.HTM. I mean like when we type some page address after CAR.PHP?PAGE= it will display that page. I know how to do it in ASP like:
<%
If Request.QueryString("page")="" Then ' if the main.asp?page= is blank it will display the content.asp page below
Server.Execute "content.asp"
Else ' it will load that pageeg page=downloads.asp
Server.Execute Request.QueryString("page")
End If
%>
Please tell me how we do it in PHP. Please.
Thanks.
PHP ?page= SYSTEM
Moderator: General Moderators
-
Paddy
- Forum Contributor
- Posts: 244
- Joined: Wed Jun 11, 2003 8:16 pm
- Location: Hobart, Tas, Aussie
- Contact:
Code: Select all
<?php
if ($_GET['page'] == "")
header("Location: content.php");
else
{
$url = "Location: ".$_GET['page'];
header($url);
}
?>another option !
(hybride)
Here is $cancel the name for a image field (!on submit this var wil be renamed to cancel_x and cancel_y )
btw i copy past this from a working model
(hybride)
Code: Select all
<?if (isset($cancel_x)){
echo "<script> parent.mainFrame.location=('../../main.php?map=".$map."&alias=".$alias."&event=".$event."');</script>"; ?>Here is $cancel the name for a image field (!on submit this var wil be renamed to cancel_x and cancel_y )
btw i copy past this from a working model
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
This code would not work if register_globals was off. register_globals is off by default and deprecated. Judas, please ensure that you have read Before Post Read: General Posting Guidelines.Judas wrote:another option !
(hybride)
Code: Select all
<?if (isset($cancel_x)){ echo "<script> parent.mainFrame.location=('../../main.php?map=".$map."&alias=".$alias."&event=".$event."');</script>"; ?>
Here is $cancel the name for a image field (!on submit this var wil be renamed to cancel_x and cancel_y )
btw i copy past this from a working model
It also requires JavaScript on to run (although there's no indication of which language the <script> tags enclose I assume it's JS) and is for use on a site using frames, which doesn't seem to be what the original poster had.
Mac
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Another piece of alternative code could be:
As I state in the comments, please do some validation on the user input before just including whatever they put in the query string.
Mac
Code: Select all
<?php
if (empty($_GET['page'])) {
include 'content.php';
} else {
// make sure that you do some validation of this variable though,
// you don't want people to be able to include their own pages for
// example and use them to find sensitive information on your system.
// You need to check that the page is on your server, not on a remote
// server and that it is not a sensitive file that you wouldn't want
// users to see.
include $_GET['page'].'.php';
}
?>Mac