Reply to Re: [PHP] Simple question: $_POST

Your name:

Reply:


Posted by Jochem Maas on 01/14/05 20:42

Stuart Felenstein wrote:
> When using $_POST vars is it required that a form is
> used ?
>
> In other words I can create an href link and echo
> variable and pick them up using $_GET in the following
> page.
>
> No so with $_POST ?

in order to create POST vars the proper request headers need to sent to
the browser. that could be done with some newfangled javascript
techniques e.g. XHTTPRequest object - see sitepoint.com (Harry Fuecks
article)

if you don't care if a var comes via post or get you could use a func
like this to avoid having to check both superglobals everytime

/**
* getGP()
*
* this function will return the value of a GET or POST var that
corresponds to the
* variable name pasted, if nothing is found NULL is returned. contents
of POST array
* takes precendence over the contents of the GET array. You can
specify a value as second argument
* which will be returned if the GP var *does not* exist; a third
parameter can be given to
* which will act as the return value if the GP *does* exist - the
limitation is that the parameter cannot be
* used to return a literal NULL; but I suggest that this would
probably be a silly thing to do in practice
*
* @var string $v // the name of GP variable whose value to return
* @var mixed $r // value to return if the GP variable was not set
* @var mixed $t // value to return if the GP variable was set (i.e.
override the value from GP)
*
* @return mixed
*/
function getGP($v = '', $r = null, $t = null)
{
if (!empty($v)) {
if (isset($_GET[$v])) { $r = (!is_null($t)) ? $t: $_GET[$v]; }
if (isset($_POST[$v])) { $r = (!is_null($t)) ? $t: $_POST[$v];}
}

return $r;
}


>
>
> Stuart
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация