My Account   Contact Us    
  
» HomeProductsSupportDeveloper CommunityCompany
POST variables
Author: Greg Alton
Category: ColdFusion
Get easy access to form post variables when register_globals = off.
The following makes it easy to reference form post variables in your form action page when register_globals = off. It will also work in PHP 3 where superglobals are not present.

A form variable named firstname would then be referenced as $firstname in the page.

<?php
     while (list ($key, $val) = each ($HTTP_POST_VARS)) {
        $$key = $val;
     }
?>

How does it work? $HTTP_POST_VARS is an array that looks like:

$HTTP_POST_VARS = array("firstname"=>"Greg", "lastname"=>"Alton");

list() searches through the array for key value pairs and $$key converts the name of the form variable into a new variable name. The value of the variable is then assigned.


Content Management Powered by ActivEdit  ActivEdit Browser Based WYSIWYG HTML Editor

More Code Samples

Sign up for our newsletter: | Subscribe with RSS: RSS
© ActivSoftware 1999 to 2005 | Privacy Statement