First, read this:

  http://www.php.net/variables.external

Second, assuming you have a PHP version equal to
or greater than 4.1.0 and the method of the form
is POST, you'd do something like this:

  $banlist = array('[EMAIL PROTECTED]');
  echo check_banlist($banlist, $_POST['email']);

Your question sounds like you're wondering if the
function definition should change, it doesn't.  You
leave it as $email and use $email within the function.
This is just how functions work, you pass in values.
So:

  function foo ($email) {
      print $email;
  }

  foo($_POST['email']);

  // Or as you used to do with register_globals
  foo($email);

Or you could always just do:

  function bar () {
      print $_POST['email'];
  }

  bar();

This is why they are SUPERglobals, because this is
what you would have done in the past (old school):

  function baz () {
      global $email, $HTTP_POST_VARS;

      print $email;

      print $HTTP_POST_VARS['email'];
  }

Also it's worth mentioning that $HTTP_POST_VARS has 
existed since PHP 3, so just in case that might be 
important to you too.  It is not super.

Now if you don't care if 'email' comes from GET, POST,
or COOKIE ... you could use $_REQUEST['email'].  Or,
import_request_variables() is another option.  For
example:

  import_request_variables('p', 'p_');

  print $p_email;

See the manual for details, and have fun!  It really
isn't that complicated and you'll be yelling out
Eureka! pretty soon now.

Regards,
Philip Olson

P.s. Superglobals work with register_globals on or off.


On Thu, 19 Dec 2002, Jamie wrote:

> I am attempting to modify an old script to support the superglobal 
> $_POST with register_globals=Off.  These register globals are definately 
> challenging when you are new to php and every example shown anywhere 
> uses the old method but I guess what doesn't kill you only makes you 
> stronger.
> 
> I am trying to convert this line, $email is coming from an html form so 
> I would typically call it with $_POST['email'] but this doesn't work in 
> this case and I thus far haven't been able to find anything that 
> explains what I should be doing.
> 
> function check_banlist($banlist, $email) {
> 
> Any assistance is appreciated!  Thanks,
> 
> Jamie
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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

Reply via email to