check boxes
Moderator: General Moderators
check boxes
In asp or coldfusion, when I submit a list of check boxes to action page, I am able to get the values of all the check boxs with a comma(,) delimiter. But the same is not happening with php? What are the reasons for that?
page.htm
===
<form name="form1" method="post" action="form2.php">
<input type="checkbox" name="linc" value="1">1
<input type="checkbox" name="linc" value="2">2
<input type="checkbox" name="linc" value="3">3
<input type="checkbox" name="linc" value="4">4
<input type="checkbox" name="linc" value="5">5
<input type="submit" value="submit" name="somename">
</form>
=======
page2.php
=========
<?
echo $_POST['linc'];
?>
the page2.php is showing only one value if we check more then one value
===
<form name="form1" method="post" action="form2.php">
<input type="checkbox" name="linc" value="1">1
<input type="checkbox" name="linc" value="2">2
<input type="checkbox" name="linc" value="3">3
<input type="checkbox" name="linc" value="4">4
<input type="checkbox" name="linc" value="5">5
<input type="submit" value="submit" name="somename">
</form>
=======
page2.php
=========
<?
echo $_POST['linc'];
?>
the page2.php is showing only one value if we check more then one value
of course it will only show one value
a. you dont have an array to arrange multiple variables if multiple variables are checked
b. seeing u dont have an array, you have name = linc for all your inputs, hence making only one variables regardless.
try.
I think that will do the trick
a. you dont have an array to arrange multiple variables if multiple variables are checked
b. seeing u dont have an array, you have name = linc for all your inputs, hence making only one variables regardless.
try.
Code: Select all
<?php
<form action=form2.php?$linc method=POST>
<input type=checkbox name=linc[] value="1">1
<input type=checkbox name=linc[] value="2">2
<input type=checkbox name=linc[] value="3">3
<input type=checkbox name=linc[] value="4">4
<input type=checkbox name=linc[] value="5">5
</form>
// form2.php
if (isset($linc)) {
// here use a foreach or while loop to display all your array info, i'm not going to write that for you
}
?>