Page 1 of 1

check boxes

Posted: Fri Mar 26, 2004 11:36 pm
by call
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?

Posted: Sat Mar 27, 2004 12:01 am
by bawla
wut does your script look like?

Posted: Sat Mar 27, 2004 6:29 am
by call
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

Posted: Sat Mar 27, 2004 2:02 pm
by tim
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.

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
}
?>
I think that will do the trick