Re: recover values independently of GET or POST used
| From: | TG | Date: | Tue, 15 Sep 2009 03:01:01 +0000 |
| Subject: | Re: recover values independently of GET or POST used | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-46505@lists.php.net to get a copy of this message | ||
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@alejandro.ceballos.info
To: php-db@lists.php.net
Date: Mon, 14 Sep 2009 19:41:24 -0700
Subject: [PHP-DB] 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
>
>