jrg70 Posted October 2, 2006 Posted October 2, 2006 I’m writing page hits to a log file and I need to know the variables that are passed along with the actual php page or the results written to log file are useless. $_SERVER['PHP_SELF'] gives me the name of the file executing the script (index.php or this_page.php), but not the accompanying variables. Is there a way to give me the variables passed through the url as well? (For example: www.example.com/index.php?var=test) I would like to get the “?var=test” information. Quote
TCH-Bruce Posted October 2, 2006 Posted October 2, 2006 You either need to turn Register Globals to ON or use the $_GET[varname] to access the variables you are passing. Quote
jrg70 Posted October 2, 2006 Author Posted October 2, 2006 You either need to turn Register Globals to ON or use the $_GET[varname] to access the variables you are passing. The problem with $_GET[varname] is that you have to know the varname you're looking for. Is there no way of actually getting the information that is in the url box on the browser? Quote
TCH-Bruce Posted October 2, 2006 Posted October 2, 2006 Since you are using php check out the documentation on parse_url Quote
jrg70 Posted October 2, 2006 Author Posted October 2, 2006 Since you are using php check out the documentation on parse_url Thanks for another reply. I think that may work, but how do I actually get the url from the page I'm working on. Meaning. The url will be dynamicaly generated by what the user may select from the page before. I need to get the url that is currently being displayed. I hope you understand what I'm asking, or am I talking in circles. Quote
click Posted October 2, 2006 Posted October 2, 2006 $_GET is simply an associative array containing all the variables passed through the url so you should be able to use foreach() to loop through them all. Quote
telcor Posted October 4, 2006 Posted October 4, 2006 As click said, something like this will work: >foreach($_GET as $key=>$value){ //... } That gives you both the variable name and the value. Don't forget to validate and sanitize both the data and variable names before using them. Quote
jrg70 Posted October 5, 2006 Author Posted October 5, 2006 Thanks for all the help. That was what I was looking for. I didn't realize that $_GET was an assoc array. Thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.