[PHP] Re: Alternate To Making Form Variables Global (Clerified)

2002-05-06 Thread Julio Nobrega Trabalhando

  This is not the global that is meant on the update. Not the global $var
that you put inside your functions.

  That's scope, btw. You are making a variable available inside a different
scope (the function), by making it global.

  The global you are searching for is, like when you submit a form, a field
name becomes a varible on the action page with the same name. So:

input name=username...

  Would create a $username variable. Not anymore :-)

  Now you need to specify where it came from, either with $_POST or
$HTTP_POST_VARS.

  So... action page again:

$username = $_POST['username'];

  But, if you don't want to convert your script (and I object btw, you
should ;-), you can modify a line at php.ini so variables are *globally
registered* again.

--

Julio Nobrega.

Um dia eu chego lá:
http://sourceforge.net/projects/toca

Ajudei? Salvei? Que tal um presentinho?
http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884


Dr. Shim [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Sorry, I'll have to clerify myself a bit. I'm rather tired. :)

 I have a script that verifys and inserts (into and Access databse) form
 values. I had to make the form variables global, in order to use them in
 my functions. Since the new PHP is out, the script doesn't work anymore. I
 think its probably because of the fact that I had to make those variables
 global (none of the variables are being read).
 Does any of you have an idea about how I can fix this problem? Thanks in
 advance.


 Dr. Shim [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Is there another way then to register form variables global? I just
 downloaded, and instlaled the newest version of PHP, and now my form
script
 doesn't work anymore.  I had to register the form variables global in the
 script. I'm asking, is there a better way of doing this? I've herd it can
 lead to possible security hazards.

 Thanks for any help.







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Alternate To Making Form Variables Global (Clerified)

2002-05-06 Thread Austin Marshall

Dr. Shim wrote:
 Sorry, I'll have to clerify myself a bit. I'm rather tired. :)
 
 I have a script that verifys and inserts (into and Access databse) form
 values. I had to make the form variables global, in order to use them in
 my functions. Since the new PHP is out, the script doesn't work anymore. I
 think its probably because of the fact that I had to make those variables
 global (none of the variables are being read).
 Does any of you have an idea about how I can fix this problem? Thanks in
 advance.
 
 
 Dr. Shim [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Is there another way then to register form variables global? I just
 downloaded, and instlaled the newest version of PHP, and now my form script
 doesn't work anymore.  I had to register the form variables global in the
 script. I'm asking, is there a better way of doing this? I've herd it can
 lead to possible security hazards.
 
 Thanks for any help.
 
 
 
 

Look into the extract() function.  You could use it to turn the $_POST 
or $_GET arrays into local variables, whether you do it at the beginning 
of the script and make them global as you are currently doing or by 
doing it at the beginning of the functions that you use them, without 
globalizing anything.



For example... given the url http://localhost/foo.php?bar=banana

you'd have $_GET['bar']==banana instead of $bar==banana;

at the beginning of the script you'd have extract($_GET); and $bar would 
exist with the value banana


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Alternate To Making Form Variables Global (Clerified)

2002-05-06 Thread Dr. Shim

Thank you so much Austin, and Julio! Your replies are an amazing help to me.
Thanks! Maybe I'll even get this project I'm working on done this week. =)

Anyhoo, Julio, you mean that option in the PHP.INI, is it
register_globals? Well, anyhow, I'm going to convert my script, as you
put it.

Again, thanks for your help, I'm going to definatly look up the extract()
function, Austin.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php