Re: Get "nice" variables from POST

From: Date: Fri, 12 Mar 2004 15:01:41 +0000
Subject: Re: Get "nice" variables from POST
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-180261@lists.php.net to get a copy of this message
if (is_array($_POST)) { foreach($_POST as $name=>$value) { ${$name} = $value; } } /tom On Fri, 12 Mar 2004 15:59:00 +0100 (CET) Hans Juergen von Lengerke <lengerkeh@sixt.de> wrote: > I know this isn't what you want, but nevertheless, this > "does not look ugly": > > <pre> > > # Get variables from the form > # > $username = $_POST['username']; > $password = $_POST['password']; > $password2 = $_POST['password2']; > $email = $_POST['email']; > $email2 = $_POST['email2']; > $nickname = $_POST['name']; > $city = $POST['city']; > $state = $_POST['state']; > $country = $_POST['country']; > $misc = $_POST['misc']; > $country = $_POST['country']; > > </pre> > > and there you go, you can now easily spot a typo too :-) > > Hans > > > PS: If you read this with variable-width font > you might think I am an idiot. never mind. > > > > Date: Thu, 11 Mar 2004 14:51:25 +0000 > > From: Mike Mapsnac <mikerh9@hotmail.com> > > To: php-general@lists.php.net > > Subject: [PHP] Get "nice" variables from POST > > > > I have about 10 fields in the form. And I get the fields through POST: > > //Get Variable from the form > > $username = $_POST['username']; > > $password = $_POST['password']; > > $password2 = $_POST['password2']; > > $email = $_POST['email']; > > $email2 = $_POST['email2']; > > $nickname = $_POST['name']; > > $city = $POST['city']; > > $state = $_POST['state']; > > $country = $_POST['country']; > > $misc = $_POST['misc']; > > $country = $_POST['country']; > > > > It works but it looks ugly. For each variable I have statemet. Is there a > > way to get the variables in the loop? > > > > I'm looking for "nice" way to get variables from POST? > > > > Thanks > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php --

« previous php.general (#180261) next »