-
i forgot what to do
What do i need to change in the apache server config file to have it so it automatically takes variables from the URL?
like if i have a url like this:
www.site.com/index.php?id=1
how do i setup apache so that it sets the $id variable to one with that url? Someone offerred me hosting for a site of mine and there apache isnt parsing the id variable :(
-
its called register_globals i think.
-
it isn't parsing it because register_globals is off. you need to use teh super globals to get the url variable and that global is $_GET[].
so in this example it would be
www.site.com/index.php?id=1
$ID = $_GET[id];
echo $ID; // ID =1
-
Re: i forgot what to do
Quote:
Originally posted by stickman373
What do i need to change in the apache server config file to have it so it automatically takes variables from the URL?
like if i have a url like this:
www.site.com/index.php?id=1
how do i setup apache so that it sets the $id variable to one with that url? Someone offerred me hosting for a site of mine and there apache isnt parsing the id variable :(
The register_globals is in the php.ini file. It has nothing to do with apache.
And I would go with phpman and recommend you use the superglobals, ie $_REQUEST['id'] or $_POST/$_GET['id']
-
how can i have it so if there is no id stated when using $_REQUEST['id'] that it doesn't give an error it just sets 1 as the id by default?
-
maybe this:
PHP Code:
if(isset($_REQUEST['id'])){
$id = $_REQUEST['id'];
} else {
$id = 1;
}
and lets await the onslought of corrections
-
well it works, so thanks :)
-