Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Arrays within $_POST not working?


Recommended Posts

We've just bought some hosting for a new website. Everything seemed fine until I tried to install oscommerce, the install procedure was creating strange errors. I gave up the install script and put it on manually, now there is still a problem.


I think I've narrowed it down to a problem with PHP receiving data from forms in arrays.


Here is a quick example using checkboxes:


if ($_GET['sent'] == true) {
<?php print_r($_POST); ?>
<?php } ?>

<form action="test.php?sent=true" method="post">
<input type="checkbox" name="test[]" value="1243">
<input type="checkbox" name="test[]" value="234">
<input type="checkbox" name="test[]" value="122">
<input type="checkbox" name="test[]" value="343">
<input type="submit">


When the form is submitted, the print_r shows (when any of the checkboxes are ticked, otherwise an empty array is produced):


[test] => 


The expected result would be something similar to:


[test] => Array
		[0] => 234
		[1] => 122



This has got me really confused, the only I can think of is a php.ini setting issue or something similar.


Does anyone have any suggestions?


Non-working page:


Expected result: http://www.firstclasswatches.co.uk/test.php




no outside links please

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...