note 21113 added to language.variables.predefined

From: Date: Mon, 29 Apr 2002 18:10:35 +0000
Subject: note 21113 added to language.variables.predefined
Groups: php.notes 
Request: Send a blank email to php-notes+get-29986@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] . "-"); } ?> -- http://www.php.net/manual/en/language.variables.predefined.php http://master.php.net/manage/user-notes.php?action=edit+21113 http://master.php.net/manage/user-notes.php?action=delete+21113 http://master.php.net/manage/user-notes.php?action=reject+21113

« previous php.notes (#29986) next »