- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi,
I have a url such as domain.com/search.php?q=ipad&page=23&v=0&v2=2
My problem is how can I obtain and use all of these variables? The variables q and page are static and I can call them independently however for some of the v & v2 variables it is difficult to as these are static.
Thanks,
Jack
How do you want to use them, in what language? PHP? JavaScript?
Hi,
Thanks for your reply. Yes in PHP.
I use the $_GET, however I don’t how this would work with any variables attached to the url which are dynamic and generated by the system or external API queries.
I use the $_GET, however I don’t how this would work with any variables attached to the url which are dynamic and generated by the system or external API queries.
Very simply: check for variables you expect, and refuse all that you don’t.
For example, if you might get the params a
, b
, and c
, then check for them:
$a = isset( $_GET['a'] )? $_GET['a']: null;
$b = isset( $_GET['b'] )? $_GET['b']: null;
$c = isset( $_GET['c'] )? $_GET['c']: null;
Or, if your program depends on these vars for decisions:
if( isset( $_GET['a'] ) ){
/* do "a" stuff */
}
// etc. …
If someone sends you a parameter d
in the query string, and you aren’t expecting it, then trying to do something with it would be a critical security risk. Don’t do it.