Jump to content

Help with variables and server


rckehoe

Recommended Posts

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

Link to comment
Share on other sites

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'];

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.