my checkbox array striped ?
| From: | adwinwijaya | Date: | Wed, 03 Mar 2004 23:27:44 +0000 |
| Subject: | my checkbox array striped ? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-179385@lists.php.net to get a copy of this message | ||
Hi all,
I have a script like this:
in html
<form name="form" action="process.php" method="post">
<input name="type[]" type="checkbox" id="type[]"
value="1" checked>
<input name="type[]" type="checkbox" id="type[]"
value="2" >
<input name="type[]" type="checkbox" id="type[]"
value="3" >
<input name="type[]" type="checkbox" id="type[]"
value="4" >
<input name="type[]" type="checkbox" id="type[]"
value="5" >
<input type="text" name="xyz">
<input type="submit" name="Submit" value="GO">
</form>
and in process.php I have:
<?php
function stripTags($value){
if(isset($value))
return strip_tags($value);
}
if(isset($_POST)){
foreach($_POST as $key=>$value){
$_POST[$key] = trim($value);
$_POST[$key] = stripTags($value) ;
}
}
print "<pre>" ;
print_r($_POST);
print "</pre>" ;
?>
and the output will be :
Array
(
[type] => Array
[xyz] =>
[Submit] => GO
)
as you can see the type should be an array ... but it just displaying
Array ....
if I remove strip_tags from my script it will work perfectly (it will
display the checkbox array) ...
can someone explain to me why this happen ? I just want to strip tags
every input the user entered ...
thanks
--
Best regards,
adwin