Re: Are $_POST and $_GET interchangable?

From: Date: Wed, 10 Mar 2004 11:07:41 +0000
Subject: Re: Are $_POST and $_GET interchangable?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-180002@lists.php.net to get a copy of this message
Hi You can use both $_GET and $_POST at the same time. As an example imagine that you had a script that generated a HTML form for collecting data. And image that that script generated different forms on the basis of a parameter passed in the URL (i.e. a $_GET value). Of the top of my head like this: <form metod="post"> <?php switch($_GET['formid']) { case 1: echo 'enter your name:<input type="text" name="name" value="'.$_POST['name'].'"/>"; break; case 2: echo 'enter you telephone number:<input type="text" name="tel" value="'.$_POST['tel'].'"/>"; break; default: echo "oops, no form ID"; break; } ?> <input type="submit"/> </form> you could imagine calling this as follow: http://www.yoursite.com/form.php?formid=1 or http://www.yoursite.com/form.php?formid=2 HTH Henry "David Jackson" <lists@mustardandrelish.com> wrote in message news:20040310105942.97298.qmail@pb1.pair.com... > I understand the difference between how they process from data. > Most application seem to reply on $_GET which display the > session/from/cookie values in the URL windows. > > What I'm not clear on are there times when you have to either $_POST or > $_GET? > > TX, > david

« previous php.general (#180002) next »