Skip to content
Advertisement

$_POST not being set

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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement