I have a strange problem.
Situation:
I have a form with the method ‘post’.
Inside that form I have 1 checkbox and a submit button.
When i press the submit button an if statement will catch wether the post var is isset.
Problem:
When i press the submit button, it randomly doesn’t work.
So I press it now and it works or it won’t.
Here is the code I use to catch the post
if ( isset ( $_POST['mail_subscribe'] ) ) {
//My code here
}
And here is the code from the form (I’m using smarty)
<form action="/my/url.html" method="post">
<input type="checkbox" name="mail_subscribe" class="mail_subscribe" id="{$var.graph1.ID}" {if $var.mailing == 1}checked="checked" value="0"{else}value="1"{/if} />
<br /><br />
<input type="submit" value="save" id="mailing_submit"/>
</form>
When i submit this form sometimes it works and more often it doesn’t.
If you guys need more information let me know.
I’ll update the question asap.
ANSWER
I found the answer to my problem.
Thank you @RobertMaysJr for that.
When a checkbox is not checked, and it is the only field inside the form, the form will never submit.
Now that I know that I’m changing the way I’ll be doing this 🙂
it needs to always be value=”1″ – if the checkbox is not checked then it won’t be submitted at all by the browser