note 21113 deleted from language.variables.predefined by philip

From: Date: Tue, 16 Jul 2002 17:05:04 +0000
Subject: note 21113 deleted from language.variables.predefined by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-33153@lists.php.net to get a copy of this message
With PHP 4.2 you cannot access the variables except with $_POST ($HTTP_POST_VARS). If your HTML code has an array submission then you can pick the data off like this. It is simple but handy if you do not want to change a lot of PHP code that was written for earlier versions with register_globals on /////////////// HTML CODE ///////////// <html> <head> <title>Sample Page</title> </head> <body> <form method="POST" action="test.php"> <input type="text" name="T1" value="hello"> <input type="checkbox" name="CB1[]" value="1"> <input type="checkbox" name="CB1[]" value="2"> <input type="checkbox" name="CB1[]" value="3"> <input type="checkbox" name="CB1[]" value="4"> <input type="checkbox" name="CB1[]" value="5"> <input type="submit" value="Submit" name="B1"> </form> </body> </html> //////////////////// PHP (http POST)FORM PROCESSING /////////////////////////// <?php /****global $T1, $CB1; Does not work with PHP 4.2 *****/ echo("Printing Out Check Box Elements:"); if(isset($_POST[ "CB1" ])) $size = count($_POST[ "CB1" ]); else $size = 0; for($i=0; $i < $size; $i++) { echo("[" . $i . "]="); //if( isset($_POST[ "CB1" ][$i]) ) echo ($_POST[ "CB1" ][$i] . "-"); } ?>

« previous php.notes (#33153) next »