Forum Moderators: coopster

Message Too Old, No Replies

How to have a dynamic url like index.php?id=10

         

adder

1:18 pm on Feb 26, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi,

Could you pleas advise on how do I best make dynamic addresses like filename.php?id=10 etc.

I just switched to a new filing system but I still have six urls within GG results which should respond to filename.php?id=10 and so on.

My server doesn't support $_GET so I am thinking of a new way to make this.

Ideally, I would have six variables containing the body text and then just display the appropriate variable. Somehow I cannot figure out how.
All help appreciated!
Thanks

jatar_k

2:16 pm on Feb 26, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> My server doesn't support $_GET so I am thinking of a new way to make this.

you might need to explain how that's true or what you mean by it

adder

5:48 pm on Feb 26, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



Well, I wrote something like this:
[PHP]
$myselection = array('21','22','23','24');

if (in_array($_GET['id'], $myselection)) {
include ($_SERVER['DOCUMENT_ROOT'] . '/source/' . $_GET['id'] . '.php');
}
[/PHP]

21, 22, 23, 24 are page IDs that are still in GG results. It doesn't work. It never does if $_GET is involved. As I gather from my support they doesn't allow globals.

eelixduppy

6:11 pm on Feb 26, 2008 (gmt 0)



I never heard of a host turning of the superglobals array before....Try something really simple such as the following:

echo $_GET['test'];

and then visit the url http://www.example.com/page.php?test=Thisprints

>>As I gather from my support they doesn't allow globals.

I'd imagine they mean "register globals [us2.php.net]" which is something different.

adder

6:28 pm on Feb 26, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



Well, yes. Your test worked...
Now, how to work it over to make it function with ID?

jatar_k

6:49 pm on Feb 26, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



is it just the include that doesn't work?

maybe test the if

if (in_array($_GET['id'], $myselection)) {
echo 'includes rule!';
//include ($_SERVER['DOCUMENT_ROOT'] . '/source/' . $_GET['id'] . '.php');
} else {
echo 'that didn't work!';
}