include using $QUERY_STRING

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Swaroop
Forum Newbie
Posts: 2
Joined: Mon Sep 08, 2003 7:05 am
Location: India

include using $QUERY_STRING

Post by Swaroop »

Code: Select all

$pagetitle="$QUERY_STRING";
if (!empty($QUERY_STRING)) {
$thefile = "$QUERY_STRING.php";
if (file_exists($thefile)) {
include("functions.php"); 
include("top.php");
include($thefile); 
include("bot.php");
exit;
}
$thefile = "$QUERY_STRING.php";
include("functions.php"); 
include("top.php");
include("Error404.php");
exit;
}
$pagetitle="Home";
include("functions.php"); 
include("top.php");
include("Home.php"); 
include("bot.php");
Ok now everything's fine..
The trouble is when I access like /?Page?somevar=somevalue then it takes it as an error page of course.. Can someone give a suggestion to alter this so that using the same technique, I can send variables thru QUERYSTRING ??
Thanks,
Swaroop :D
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

/?Page?somevar=somevalue

it should be:

/page.php?somevar=somevalue

or....

(it's either my limited knowledge or your tying error or something. i think you would need to use it like:)

/?somevar=somevalue

most of the time, it won't work unless the file is index.php since like this, it looks for the index file in the directory.

hope that helps.

-Nay
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Recommend you read the last link in my signature...
($_SERVER['QUERY_STRING'])
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

/? only works on the index. /?page=1 sets a variable page to 1

/?page=1&somevar=zxy sets page to 1 and somevar to zxy

/?page=1?somevar=zxy sets page to 1 (or maybe 1?somevar=zxy)
Swaroop
Forum Newbie
Posts: 2
Joined: Mon Sep 08, 2003 7:05 am
Location: India

Post by Swaroop »

well it's something like this :
/?Page --> includes the file Page.php from the parent directory..
Now when I wanna pass the variables, I have been using /Page.php?somevar=somevalue which gives me a problem cuz functions.php and top.php must be included for all the pages.
So what I am asking is like can we pass a variable also using this technique which i use for my pages ??
example:
/?Page?somevar=somevalue
OR
/?Page&somevar=somevalue
--
Swaroop :D
Post Reply