#22626 [Com]: POST'ing an Array (<input name="checkbox[70]">) gives string 'Array'

From: Date: Tue, 13 May 2003 18:51:35 +0000
Subject: #22626 [Com]: POST'ing an Array (<input name="checkbox[70]">) gives string 'Array'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-39541@lists.php.net to get a copy of this message
 ID:               22626
 Comment by:       rajc at aol dot com
 Reported By:      cyborg at driverheaven dot net
 Status:           Bogus
 Bug Type:         *General Issues
 Operating System: Windows 2003 Server
 PHP Version:      5CVS-2003-03-10 (dev)
 New Comment:

I need to know how to use an array of checkboxes and find out if these
checkboxes are on or off.  cyborg  will you please post your code.

Here is how i am creating my checkboxes.
$tmps =	getforumtemplates();
			
if(!is_array($tmps))
{
print "<br><br>Their are no templates defined. If you would like to
enter one please click on Add New link.\n";
?>
<br>		
<?php
}//end if
else
{ $number = 0;
$arr = array();
			print "Template Name:<br>";
			foreach($tmps as $t)
			{?>	<input type="checkbox" name="templates[]">
<?=$t->name?><font
size = "-1">
																	<a
href="modifyforumtemplates.php?tid=<?=$t->templateid?>">modify</a></font><br>
			<?php 
			
				$number++;
			}
			//end foreach
			
		}
		//end else


Previous Comments:
------------------------------------------------------------------------

[2003-03-10 17:31:12] cyborg at driverheaven dot net

indeed.

------------------------------------------------------------------------

[2003-03-10 17:15:40] sniper@php.net

Not PHP bug -> bogus.


------------------------------------------------------------------------

[2003-03-10 17:09:27] cyborg at driverheaven dot net

It appears to have been my problem, as I wasn't checking for whether
the variable was an array or string, and attempting to stripslashes()
if magic_quotes_gpc was enabled.

/me smacks head for being an idiot.

(Although there was no problems with it on PHP >= 4.1.0)

------------------------------------------------------------------------

[2003-03-10 14:07:59] derick@php.net

Please show us the script in which you do the print_r().

Derick

------------------------------------------------------------------------

[2003-03-10 13:17:26] cyborg at driverheaven dot net

when posting information through a form, using an array for a name,
example:

4 inputs: <input name="checkbox[70]" type="checkbox" />

(where 70 is different for each input, according to the messageid)

PHP gives the value 'Array' for $_POST['checkbox'], and it is a string,
as print_r() displays 'Array', and is_array() returns false on check.

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=22626&edit=1



Thread (6 messages)

« previous php.bugs (#39541) next »