p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: RES: RE: RES: RE: switch problem


Message #1 by "Rodrigo Penloski - Som Livre.com" <Rodrigo@s...> on Tue, 29 Oct 2002 14:38:29 -0300
Oh.. i don't know still doesn't work, i can't figure out what is going
on here...

-----Mensagem original-----
De: David Scott-Bigsby [mailto:DScott-Bigsby@P...]
Enviada em: ter=E7a-feira, 29 de outubro de 2002 14:34
Para: beginning php
Assunto: [beginning_php] RE: RES: RE: switch problem


> Ok, i'll get with $HTTP_GET_VARS['pag'], but how do I send to it??

Oh, PHP automatically creates the array and an item (e.g., 'pag') for
each argument in the query string. You shouldn't have to do anything
except change $pag to $HTTP_GET_VARS['pag'].

dsb

***************************************       
David Scott-Bigsby
Product Manager, Web Site and PEDN

PureEdge Solutions
The Leader in Secure XML e-Forms

v:250-708-8145  f:250-708-8010
1-888-517-2675   www.PureEdge.com
***************************************


> -----Original Message-----
> From: Rodrigo Penloski - Som Livre.com
> [mailto:Rodrigo@s...]
> Sent: Tuesday, October 29, 2002 9:20 AM
> To: beginning php
> Subject: [beginning_php] RES: RE: switch problem
>
>
> Ok, i'll get with $HTTP_GET_VARS['pag'], but how do I send to it??
>
> -----Mensagem original-----
> De: David Scott-Bigsby [mailto:DScott-Bigsby@P...]
> Enviada em: ter=E7a-feira, 29 de outubro de 2002 14:03
> Para: beginning php
> Assunto: [beginning_php] RE: switch problem
>
>
> Rodrigo,
>
> > The variable $pag comes from another page through the URL:
> >
> > localhost/mytests/switch.php?pag=3Dname.
>
> You're doing it the "old way".
>
> PHP used to create variables for you based on the names in 
name=3Dvalue
> pairs, but, by default, this is turned off in more recent versions of
> PHP. You can turn this behaviour back on, although it's not
> recommended.
>
> You can get the query string values through the global array
> $HTTP_GET_VARS, e.g.,
>
> 	switch ($HTTP_GET_VARS['pag'])
> 	...
>
> There are other global arrays for the same purpose -- I think
> $HTTP_GET_VARS is deprecated in favour of $HTTP_GET or
> somesuch. (By not
> on my box -- we haven't upgraded yet.)
>
> dsb
>
> ***************************************       
> David Scott-Bigsby
> Product Manager, Web Site and PEDN
>
> PureEdge Solutions
> The Leader in Secure XML e-Forms
>
> v:250-708-8145  f:250-708-8010
> 1-888-517-2675   www.PureEdge.com
> ***************************************
>
>
> > -----Original Message-----
> > From: Rodrigo Penloski - Som Livre.com
> > [mailto:Rodrigo@s...]
> > Sent: Tuesday, October 29, 2002 6:43 AM
> > To: beginning php
> > Subject: [beginning_php] switch problem
> >
> >
> > I have this code:
> >
> > <?
> > switch ($pag) {
> > 	case 'name':
> > 	print "Joseph";
> > 	break;
> > =09
> > 	case 'mail':
> > 	print "joseph@s...";
> > 	break;
> > =09
> > 	case 'age':
> > 	print "21";
> > 	break;
> > =09
> > 	default:
> > 	print "default";
> > }
> > ?>
> >
> > The variable $pag comes from another page through the URL:
> >
> > localhost/mytests/switch.php?pag=3Dname.
> >
> > Well the problem is, it doesn't work..
> >
> > What am I doing wrong?
> >
> > Thanx in advance;
> >
> > Rodrigo
> >
> >
>
>
>

Message #2 by "Nikolai Devereaux" <yomama@u...> on Tue, 29 Oct 2002 09:57:14 -0800
Wow.  Every single email on the list this morning is a register_globals related
problem.


All variables sent through a URL parameter are GET parameters.  When sending
data to the server using a form, you can specify the method (GET or POST).

This link:

http://www.yoursite.com/index.php?yourvar=someValue


will pass the variable, yourvar, to the server.  It's value will be set to
"someValue".

In PHP, you'd access this GET variable with $_GET['yourvar'].  (That's the new
version of ($HTTP_GET_VARS).


For more information, I _strongly_ suggest you read the manual, particularly
this section:

 http://www.php.net/security.registerglobals


nik


  Return to Index