Page 1 of 1

$_GET['var_name'] solution?

Posted: Wed Feb 09, 2005 10:44 am
by alix
I have a set of scripts that i have on my server that work fine.. i have to place them on another server and as it is.. doesnt work. Its just not passing variables unless i use this ( $_GET['var_name'] ) for each variable. Is there a predefined variable along the lines of $HTTP_POST_VARS that will call all vars so it dont have to create one for each variable passed?

Posted: Wed Feb 09, 2005 10:48 am
by JayBird
what about

Code: Select all

extract($_POST);
at the top of your pages.

you really should be coding to include the $_GET methology by now tho!

Posted: Wed Feb 09, 2005 10:51 am
by alix
i'll try that....

lol, i know. *walks away ashamed*

Posted: Wed Feb 09, 2005 11:09 am
by JayBird
i actually meant

Code: Select all

extract($_GET);
:D

Posted: Wed Feb 09, 2005 11:23 am
by feyd
register globals is bad, mmkay? :lol: seriously though..

might also want to look at the smart extract I've posted about before.. which will only extract a known list of expected elements in the array given to it.

Posted: Thu Feb 10, 2005 12:03 pm
by alix
alright, i've been trying all kinds of stuff.. its just not working right.

this is what i have as a test to see what will make it work on this server .

Code: Select all

<?
$HTTP_POST_VARS;

if ($_GET&#1111;'action']=="this")&#123;

echo "hello ". $name . " it worked";

&#125; else &#123;
?>

<form name="form1" method="post" action="<? echo "testRS.php?action=this"; ?>">
  name: 
  <input type="text" name="name">
  <input type="submit" name="Submit" value="Submit">
</form>
<? 
&#125;;
?>
Ive also put the $_GET['name'] where the $name var is. i still get nothing, well i get "hello it worked" no name. i tried what bech100 said, same thing. Any idea?

Posted: Thu Feb 10, 2005 12:34 pm
by sonofslim
is that form the one you're trying to extract a variable from? because the method is set to POST, not GET. until you swap that, your vars are going to $_POST.

Posted: Thu Feb 10, 2005 6:09 pm
by RobertGonzalez
Is anything showing up in your $_REQUEST vars? Do you know what version of PHP the server is running?

Something you can try to see what is showing up in your vars is run each through a foreach loop to see what the output is:

Code: Select all

<?php

foreach ($_GET as $key => $val)
&#123;
    echo "The key is $key<br />";
    echo "The val is $val<br />";
&#125;
?>
Do this for all of your vars to see what is getting sent/requested. Just a thought. Hope it helps.

Posted: Thu Feb 10, 2005 6:34 pm
by shiznatix
wait if you use

Code: Select all

extract($_GET);
and

Code: Select all

extract($_POST);
you dont need to add the $var = $_POST['var'] stuff??

Posted: Thu Feb 10, 2005 6:37 pm
by feyd
yes, however you should be careful of what is extracted, and also where this happens. Use a restricted extractor, like one I've posted previously for a safer extraction.

Posted: Fri Feb 11, 2005 10:00 am
by alix
being that im having this problem on this new server im workign with and not my own.. i just compaired the phpinfo() on both servers.. on the one, the server im having no problem with, the variables_order is set to EGPCS and on the other it just has no value. Could this be why im having so many problems?

Posted: Fri Feb 11, 2005 10:55 am
by feyd
EGPCS only applies to register_globals being on and the filling of $_REQUEST in how data is stored.. nothing more that I'm aware of.

Posted: Sat Feb 12, 2005 12:19 am
by n00b Saibot
try this

Code: Select all

<? 
if (isset($_POST&#1111;'name'])) 
    echo "Hello ". $_POST&#1111;'name']. " It does work!"; 
else &#123; 
?> 

<form method="post" action="<?=$_SERVER&#1111;'PHP_SELF']?>"> 
  name: <input type="text" name="name"> 
  <input type="submit" name="Submit" value="Submit"> 
</form> 
<? 
&#125;; 
?>
and tell me what happens.