URL variables

A

Anonymous

Guest
i am new to PHP totally. All i can do is includes. :cry:

what i would like to be able to do is declare a set of variables that have URLs as their values. then use the $HTTP_GET_VARS: thing to get the page and have it display it.

the variables i have no idea how to do but i think i know how to do the get:

Code:
$HTTP_GET_VARS['$variable']

am i right?

could someone show me how this works? thanks
 
To use variables as part of a url you just make up the URL in the following format:
page.php?var1=value1&var2=value2
You might also want to have a look at the urlencode() function too!

On the page accessed using these variables, you can use a multitude of methods.
If the register_globals setting is ON (set to off in PHP 4.2.0 and later by default), you can just call $var1 and $var2.
Otherwise you can use $HTTP_GET_VARS['var1'] and $HTTP_GET_VARS['var2'].
In PHP 4.1.0 and later they've introduced Super Global Arrays, so you can access them by $_GET['var1'] and $_GET['var2']. As these arrays are Super Global, there's no need to declare them as global in functions!

BTW, you're not the same shufty as on a popular DVD forum, are you? :wink:
 
no im not im afraid.

so how would i declare a load of variables then. like this
Code:
$HTTP_GET_VARS['$var, $var2, $var3.....']
this
Code:
$_GET['$var, $var2, $var3.....']
or this
Code:
$var=./page/page/page.php, $var2=./page/........., $var3=./page/..........

what i am try to achieve is this

http://site.com/page.php?load=a/new/page.php

am i close with that?
 
shufty said:
no im not im afraid.

so how would i declare a load of variables then. like this
Code:
$HTTP_GET_VARS['$var, $var2, $var3.....']
this
Code:
$_GET['$var, $var2, $var3.....']
or this
Code:
$var=./page/page/page.php, $var2=./page/........., $var3=./page/..........

what i am try to achieve is this

http://site.com/page.php?load=a/new/page.php

am i close with that?
What do you mean by declare? PHP isn't like Perl where you have to declare a variable, you can just use it!

To access the variables on the page generated from the 'GET' variables, just use $_GET['varname'] to access the value. All the GET, POST, SESSION, COOKIE and SERVER variables are posted within their own Super Global Arrays accessed by the method $_ARRAYNAME['varName']

Once you've made up your URL as you've written it, on the next page you can use $_GET['load'] which would give you the value "a/new/page.php"
 
sorry, i'm lost now.

could you show me how i would assign the values to the variables and then structure the URL.

thanks :cry:
 
shufty said:
sorry, i'm lost now.

could you show me how i would assign the values to the variables and then structure the URL.

thanks :cry:
I already have, in as simple english I could possibly make it. Re-read the thread again!
 
Back
Top