-1

I know there's a ton of these questions and I'm prepared to take the flak for asking another one as after an hour reading through them all I just can't see what's wrong. It's my first day using PHP so maybe I'm missing something obvious.

I'm using Twitter-Bootstrap and have set up a checkbox:

<div class="checkbox">
    <label><input type="checkbox" id="mailing" name="mailing"> My label message </label>
</div>

In the php I have:

$mailing=$_POST['mailing'];
echo $mailing;

As well as a number of other POSTS. They all work fine except for this one which triggers the error "Undefined index: mailing in (my file etc, at line 14)"

The name 'mailing' is identical in the HTML and PHP, so what's going wrong?

Thanks.

Absinthe
  • 3,258
  • 6
  • 31
  • 70
  • Can you share the HTML and PHP code, so that we can verify that other input elements are going thru but only this giving problem. – Milan Chheda May 28 '17 at 12:08

1 Answers1

1

Have you tried it with the checkbox checked? See How to read if a checkbox is checked in PHP? - you should check the value with isset, because if the checkbox is not checked, there is not $_POST['mailing].

Gerriet
  • 1,302
  • 14
  • 20