$_GET['var_name'] solution?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alix
Forum Commoner
Posts: 42
Joined: Thu Nov 18, 2004 8:41 am

$_GET['var_name'] solution?

Post 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?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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!
alix
Forum Commoner
Posts: 42
Joined: Thu Nov 18, 2004 8:41 am

Post by alix »

i'll try that....

lol, i know. *walks away ashamed*
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

i actually meant

Code: Select all

extract($_GET);
:D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
alix
Forum Commoner
Posts: 42
Joined: Thu Nov 18, 2004 8:41 am

Post 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?
sonofslim
Forum Newbie
Posts: 5
Joined: Thu Feb 10, 2005 12:14 pm

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
alix
Forum Commoner
Posts: 42
Joined: Thu Nov 18, 2004 8:41 am

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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.
Post Reply