0

When submitting my form, sometimes the $_POST array is empty and other times it's not (when inputting the exact same thing on the exact same input). My post_max_size is large 500M and I'm only inputting values from checkboxes. What could be causing this? I might have thought it was because of a for loop I'm using, but the $_POST array is fine half the time and empty the other.

 <form action="send.php" method="post" enctype="multipart/form-data">
    <input type="checkbox" name="Facebook" value="Facebook" id="Facebook"/>
    <input type="checkbox" name="Twitter" value="Twitter" id="Twitter"/>
    <?php
    for($i = 0; $i < $blogcount; $i = $i + 1){
    echo '<input type="checkbox" name="Tumblr[]" value="'.$bloglist[$i].'" id="Tumblr'.$bloglist[$i].'"/>';
    } 
    ?>
    <input id="myImage" type="file" accept="image/*" name="file" class="upload" />
    <input type="submit">
</form>
5
  • do you need this enctype="multipart/form-data" for normal post?? Commented Oct 27, 2015 at 4:46
  • you have missed a quote in echo at last add one single quote. Commented Oct 27, 2015 at 4:48
  • Oh, I do have an image input that I've just removed only for testing purposes (as I thought it might've been enctype making the array empty, but it wasn't), I'll add it into the code Commented Oct 27, 2015 at 4:49
  • Sorry, I was typing it out by hand, the last quote was there in the real code... Commented Oct 27, 2015 at 4:50
  • See your source code in html. How the outputs look like. Is that really what you want. Commented Oct 27, 2015 at 5:01

3 Answers 3

1

If you don't check any checkbox, it won't post and thus it would give you empty $_POST. All you have to code is isset($_POST['checkboxname'])

Sign up to request clarification or add additional context in comments.

1 Comment

All the checkboxes were ticked, and I've been testing with isset(...). Eventually I've just started doing var_dump($_POST);die(); but same result...
0

Try this

<?php
    for($i = 0; $i < $blogcount; $i = $i + 1){
        ?>
        <input type="checkbox" name="Tumblr[]" value="<?php echo $bloglist[$i] ?>" id="<?php echo 'Tumblr'.$bloglist[$i] ?>"/>
    <?php
    } 
?>

2 Comments

Unfortunately the same result after a few successful ones. Thanks though!
@Hook happy to help :)
0

I think you have add value to your submit button to work correctly.

<input type="submit" value="submit" name="submit">

1 Comment

And how'll that help him

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.