R: R: [PHP] Get "nice" variables from POST

From: Date: Fri, 12 Mar 2004 14:22:56 +0000
Subject: R: R: [PHP] Get "nice" variables from POST
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-180257@lists.php.net to get a copy of this message
hi, curly braces are useful to specify in a double quoted string where is the end of the variable name. "$ciao" == "${ciao}" in case of associative arrays is recommended to prevent the parser to mess up. see php manual at the following section for details Main : Language Reference : Types : Strings -----Messaggio originale----- Da: Mike Mapsnac [mailto:mikerh9@hotmail.com] Inviato: venerdì 12 marzo 2004 14.40 A: avitale@tiscali.com; php-general@lists.php.net Oggetto: RE: R: [PHP] Get "nice" variables from POST I try to use quotes in the query and this doesn't work. $query = "SELECT * FROM user WHERE user_id = '$_POST['user_id']}'"; But you use brackets and it works.. Why do you use brackets ? $query = "SELECT * FROM user WHERE user_id = ${_POST['user_id']}"; >From: "Alessandro Vitale" <avitale@tiscali.com> >To: "Mike Mapsnac" <mikerh9@hotmail.com>,<php-general@lists.php.net> >Subject: R: [PHP] Get "nice" variables from POST >Date: Thu, 11 Mar 2004 17:30:57 +0100 > >hi, > >why don't you simple use the $_POST vars? they are already available to >you, >so why you should copy them? > >example: > >function show_function() >{ > $query = "SELECT * FROM user WHERE user_id = ${_POST['user_id']}"; > .... >} > >at the same time: >- you save a lot of time ( you don't need to write code for copying vars ) >- you can always identify in your script the variable you are using is the >one that comes from POST > >cheers, > >alessandro > >-----Messaggio originale----- >Da: Mike Mapsnac [mailto:mikerh9@hotmail.com] >Inviato: giovedì 11 marzo 2004 15.51 >A: php-general@lists.php.net >Oggetto: [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 > >_________________________________________________________________ >Frustrated with dial-up? Lightning-fast Internet access for as low as >$29.95/month. >http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/ > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > _________________________________________________________________ Get a FREE online computer virus scan from McAfee when you click here. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

« previous php.general (#180257) next »