rckehoe Posted May 5, 2008 Share Posted May 5, 2008 I have a page that passes simple variables to another page... Example: <a href='/NewPage.php?variable=test'>My Link</a> When this link is clicked, it passes the variable just like I want to the next page.. However, you can only get the value of the variable by using the $_GET['variable']... What do I need to change on the server to get it to where I can just echo $variable instead of $_GET['variable']... Also, what is this called? I don't even know what to search on the web for... ?? Thanks in advance, Rob Quote Link to comment Share on other sites More sharing options...
Michan Posted May 5, 2008 Share Posted May 5, 2008 Why would you want to get rid of the $_GET part of it? That's the only way of reading data sent through pages using $_GET. You could always put something like this at the start of the page which is receiving the data: <?PHP $variable = $_GET['variable']; $variable2 = $_GET['variable2']; Quote Link to comment Share on other sites More sharing options...
NikkiLoveGod Posted May 5, 2008 Share Posted May 5, 2008 or you can do a loop, that will go through all the GET data ( the sent variables ) and assing a variable out of them. So $_GET['lol'] becomes $lol and so on. something like this: <?php foreach ( $_GET as $get_key => $get_val ) { $$get_key = $get_val; } ?> This way you can use the $variable names... cheers! -NikkiLoveGod Quote Link to comment Share on other sites More sharing options...
rckehoe Posted May 5, 2008 Author Share Posted May 5, 2008 Thanks for your reply's, but no... neither of those options are going to work for what I want. I am transferring to a new server, and I want it to work with every page, I know there is a better way then to go through each page and add a loop on it.. There has to be something on the server end that allows you to change this. Does anyone know? Is it located in php.ini any help, thanks! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 5, 2008 Share Posted May 5, 2008 What you are asking about is called register globals. The problem with register globals is they were such a huge blunder and security hole that they were turned off by default in php4.2 in the year 2002. No new code, new books, new tutorials, new hosting accounts after that point in time should have used them. They have been completely removed in php6. You will need to correct your code so that it uses $_GET['variable'] There is an extract() statement (use the EXTR_SKIP second parameter to prevent a hacker from overwriting your program variables) that will help if you have a lot of variables that need to be imported. Quote Link to comment Share on other sites More sharing options...
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.