does anyone have any idea why $_POST
not being set??
here is some of the code.
<form method="post" name="form" id="clientForm" action="">
<input type="submit" name="sub" value="Delete_Checked"/>
<?php if ($i%2){ ?> class="even"<?php } ?>
<input type="checkbox" name="doc[]" value="<?php echo $document->doID; ?>"/>
<?php $i++; } ?>
</form>
<?php
if (isset($_POST['sub']) == 'Delete_Checked'){
print_r($_POST[开发者_如何转开发'sub']); // nothing gets print.......
}
?>
i must be overlooking something.
If the checkbox is not checked when submitted, it won't be in the $_POST array.
$_POST itself is always set. Try this instead when you need to see everything it contains:
print_r($_POST);
Make sure you are using "post" as your form method as well.
Also, you seem to be trying to access $_POST['sub']
when your code only shows the 'doc[]` input.
if (isset($_POST['sub']) == 'Delete_Checked'){
This is not how it should be written. It will only work by accident.
What the author wanted to write was:
if (isset($_POST['sub']) && ($_POST['sub'] == 'Delete_Checked')) {
I would personally leave out the whole isset
part, because that's exactly what's obstructing your assessment of the cause.
that input should be inside form with method POST
<form action="...." method="POST">
<input type="submit" name="sub" value="Delete_Checked"/>
</form>
try to put the action to action="<?php echo $_SERVER['PHP_SELF'];?>"
精彩评论