recover values independently of GET or POST used
| From: | buzon at alejandro dot ceballos dot info | Date: | Tue, 15 Sep 2009 02:41:24 +0000 |
| Subject: | recover values independently of GET or POST used | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-46504@lists.php.net to get a copy of this message | ||
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