By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 2,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

passing Vars?

P: n/a
Hows does the passing variables from page to page work?

Specifically, when you type in a URL like:
http://www.someurl.com/test.php?someVar=20

How does the next page get, and use the variable?

Sorry for the dumb question..

Thanks

-Richard
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Richard Ragon wrote:
Hows does the passing variables from page to page work?

Specifically, when you type in a URL like:
http://www.someurl.com/test.php?someVar=20

How does the next page get, and use the variable?


$_GET['someVar'] would be set to 20
$_POST[] holds values from a POSTed form
both are merged together in $_REQUEST[]

.....unless you have an old version of php with register_globals turned
on in which case:
$someVar would be set to 20
....but I'd try not to use that anymore


Jul 17 '05 #2

P: n/a
Kevin Thorpe wrote:
Richard Ragon wrote:
Hows does the passing variables from page to page work?

Specifically, when you type in a URL like:
http://www.someurl.com/test.php?someVar=20

How does the next page get, and use the variable?


$_GET['someVar'] would be set to 20
$_POST[] holds values from a POSTed form
both are merged together in $_REQUEST[]

....unless you have an old version of php with register_globals turned
on in which case:
$someVar would be set to 20
...but I'd try not to use that anymore


Also, remember that GET, aka the way you have it (test.php?someVar=blah),
isn't the best way of doing things all the time. I find it great for
specifying the page you want to be on (ie: news.php?page=archives), and
this is how it should be used, but if you are working with form data, I
would suggest always using the POST method, as it 1. can handle more data,
and 2. hides the data from the user and makes it harder to spoof.
-Eric Kincl
Jul 17 '05 #3

P: n/a
Eric Kincl wrote:
Kevin Thorpe wrote:

Richard Ragon wrote:

Hows does the passing variables from page to page work?

Specifically, when you type in a URL like:
http://www.someurl.com/test.php?someVar=20

How does the next page get, and use the variable?


$_GET['someVar'] would be set to 20
$_POST[] holds values from a POSTed form
both are merged together in $_REQUEST[]

....unless you have an old version of php with register_globals turned
on in which case:
$someVar would be set to 20
...but I'd try not to use that anymore

Also, remember that GET, aka the way you have it (test.php?someVar=blah),
isn't the best way of doing things all the time. I find it great for
specifying the page you want to be on (ie: news.php?page=archives), and
this is how it should be used, but if you are working with form data, I
would suggest always using the POST method, as it 1. can handle more data,
and 2. hides the data from the user and makes it harder to spoof.


Basically use GET for navigation and things without side effects.
Anything which will write to your database should use POST.

Imagine a page listing every record in your database with a 'delete'
link next to it. Along comes Googlebot to index your site and merrily
deletes every record you had. Bots do not (to my knowledge) ever use POST.

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.