Re: recover values independently of GET or POST used

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some weird stuff happens when you try to chain ternary operations.  Not 
awake enough to explain it better right now.

What it sounds lik eyou're looking for is $_REQUEST.  This will give you 
the correpsonding GET or POST value (as well as cookie, environment, 
etc.. google it).

It's probably good to try to structure things so you have a predictable and 
controllable way so you know whether you're going to be getting GET or 
POST data.  Some cases required 'either' but in general, one or the other 
should be good enough if your code is structured properly.

-TG

----- Original Message -----
From: buzon@xxxxxxxxxxxxxxxxxxxxxxx
To: php-db@xxxxxxxxxxxxx
Date: Mon, 14 Sep 2009 19:41:24 -0700
Subject:  recover values independently of GET or POST used

> I am using some expressions to load the value of a parameter when  
> called, independently if used GET or POST method, using something like:
> 
> <?php
>    $mydata = (isset($_GET["mydata"])) ? $_GET["mydata"] :  
> (isset($_POST["mydata"])) ? $_POST["mydata"] : 0;
>    echo $mydata;
> ?>
> 
> The problem occurs with above code if I call it like:  
> thispage.php?mydata=something , the answer is null (not even '0').
> 
> But If I change it to:
> 
> $mydata = (isset($_POST["mydata"])) ? $_POST["mydata"] :  
> (isset($_GET["mydata"])) ? $_GET["mydata"] :  0;
> 
> It works, but only with GET method, not post.
> 
> 
> What is going on?
> 
> Everytime must be an if/elsif/else routine? What is the origin of the 
problem?
> 
> 
> TIA,
> 
>    Joal
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux