php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14811 form variables undefined on action page under certain conditions
Submitted: 2002-01-02 19:36 UTC Modified: 2002-02-26 21:27 UTC
From: ed dot swartz at sandypondconsulting dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.6 OS: Windows 2000
Private report: No CVE-ID: None
 [2002-01-02 19:36 UTC] ed dot swartz at sandypondconsulting dot com
Under certain conditions form variables are not defined. When I access a form variable by printing it out using print or print_r( get_defined_vars() ), the form variable is available and has the correct value as expected. However, when I do not print the variable and use the form variable in a foreach construct the variable is not defined. 

* register_globals is On according to phpinfo();

* I'm using session variables

* I'm using ob_start() to discard unwanted output.

* I did a standard/default installation.

I've tried simplifying the scripts to narrow down where or what is causing the problem but all my simplier scripts work fine. The following are excerpts from the original longer and more complex scripts.

// The Form page
// FileNameX strings were simplied from "c:\inetpub\wwwroot\ProjectName\Project.php"

<form action='Action.php' method='get'>
<input type='hidden' name='FormIncludes[]' value='FileName1'>
<input type='hidden' name='FormIncludes[]' value='FileName2'>
<input type='hidden' name='FormIncludes[]' value='FileName3'>
<input type='hidden' name='FormIncludes[]' value='FileName4'>
<table cols=2 width='400'>
.... HTML code omitted...
</table>
</form>


// Action.php 

<?php
// These 2 lines have been inserted into the script for debug purposes. 
// If left in as-is the variables are defined and print OK, if I comment out these 2 lines parser complains
// at the foreach loop that $FormIncludes is undefined.

	print_r( get_defined_vars() );
	print( $FormIncludes );
	
	ob_start();
		
	foreach( $FormIncludes as $FileName )
	{
		include_once( $FileName );
	}
		
	session_start();
	
	global $Form;
	
	$Form->PageProcess( $Submit );
?>

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-04 14:22 UTC] ed dot swartz at sandypondconsulting dot com
After some debugging this appears to be related to arrays. I changed the FormIncludes[] definition on the Form page to FormInclude0, FormInclude1, FormInclude2, etc. On the action page I looped through each of the form variables

$i = 0;
while( 1 )
{
$Variable = "FormInclude" . $i;
...use $$Variable...
}

This works.

 [2002-02-26 21:27 UTC] yohgaki@php.net
The version of PHP that this bug was reported in is too old. Please
try to reproduce this bug in the latest version of PHP (available
from http://www.php.net/downloads.php

If you are still able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Sep 09 08:01:28 2024 UTC