php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19981 Posted Array loses variables
Submitted: 2002-10-18 10:33 UTC Modified: 2002-10-18 15:50 UTC
From: mike at dxstorm dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.2.3 OS: Linux Redhat 7.3
Private report: No CVE-ID: None
 [2002-10-18 10:33 UTC] mike at dxstorm dot com
script below.

When posting the form with the array variables, the 
receiving function 'loses' the first 4 characters of posted 
information, whether numbers or letters.

-----start script-----
<?

$ZONES=10;

function saveInventory() {
	$counter=1;
	foreach($GLOBALS[date] as $x) {
		print "Date Array Item $counter: $x<br>";
		$counter++;
	}
	
	addInventory();
}

function addInventory() {
	global $ZONES;

	//number of inventory slots to show at a time.
	$maxslots=20;
	
	print "
	<form method=post action='test.html?action=saveinventory'>
	<table border=0>
		<tr>
		<td><b>Date</b></td>
		<td><b>Time Slot</b></td>
		<td><b>Zone</b></td>
		<td><b>Inventory</b></td>
		</tr>";
		
	for($x=1;$x<=$maxslots;$x++) {
		print "
		<tr>
		<td><input type=text name='date[$x]' size=11 maxlength=
10></td>
		<td><select name='time[$x]'>
		<option value='10am to 12pm'>10am to 12pm
		<option value='12pm to 2pm'>12pm to 2pm
		<option value='2pm to 4pm'>2pm to 4pm
		<option value='4pm to 6pm'>4pm to 6pm
		<option value='6pm to 8pm'>6pm to 8pm
		</select></td>
		<td><select name='zone[$x]'>";
		for($y=1;$y<=$ZONES;$y++) {
			print "<option value='$y'>Zone $y";
		}
		print "</select></td>
		<td><input type=text name='inventory[$x]' size=3></td>
		</tr>";
	}
	print "
		<tr>
		<td colspan=4><input type=submit value='Save Inventory'><
/td>
		</tr>
	</table>
	</form>";
}

switch($action) {
	case "saveinventory":
		saveInventory();
		break;
		
	default:
		addInventory();
		break;
}

?>
-----end script-----


----configure line----
'./configure' '--with-apxs' '--with-mysql' '--with-gd' '--
with-png-dir=/usr/lib' '--with-jpeg-dir=/usr/lib' '--with-
freetype-dir=/usr/lib' '--enable-trans-sid' '--with-xml' '-
-enable-wddx' '--enable-mbstring' '--enable-mbstr-enc-
trans' '--with-config-file-path=/etc' '--with-zlib-dir=/
usr/lib' '--enable-bcmath' '--with-curl'


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-18 15:50 UTC] sniper@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 17:01:34 2024 UTC