php - Unable to pass form values using POST method -
i'm trying pass multiple values input form (checkboxes) post method, 1 of values dumping, no matter how many checkboxes checked.. doing wrong?
var_dump($_post);
result : array(2) { ["pal_num"]=> string(1) "2" ["post"]=> string(3) "go!" }
code:
<?php $l = $_post['lt']; $pals = ''; $r = mysql_query("select distinct pal_num pl_tab lt_num='$l'"); while($row = mysql_fetch_assoc($r)) { $pals .= '<input type="checkbox" name="pal_num" value="'.$row['pal_num'].'">'.$row['pal_num'].'<br>'; } if($pal == '') echo ''; else echo '<form name="get_pal" action="post.php" method="post">'; echo $pals; echo '<input type="submit" name="post" value="go!">'; echo '</form>'; ?>
you should post array (note square brackets after pal_num
:
$pals .= '<input type="checkbox" name="pal_num[]" value="'.$row['pal_num'].'">'.$row['pal_num'].'<br>';
also, if
construct incorrect, should use brackets:
if($pal == '') { echo ''; } else { echo '<form name="get_pal" action="post.php" method="post">'; echo $pals; echo '<input type="submit" name="post" value="go!">'; echo '</form>'; }
Comments
Post a Comment