I have a form that inserts user input into a MySQL database, and one of the input field has a Boolean value. It works fine when the value is true, however if the value is false, my 'echo' and database can't receive that value at all. I really have no idea what's happening. Please take a look at my code below: HTML:
<label>
<input type="checkbox" id="consentForEmail" name="consentForEmail" />
<span class="wpcf7-list-item-label">By clicking this button I agree to receive emails from us</span>
</label>
JavaScript for collecting and setting the value:
var _this = '#consentForEmail';
$('#consentForEmail').change(function(){
var checked = $('#consentForEmail').prop('checked');
$(_this).val(checked);
console.log( $('#consentForEmail').val() );
});
And finally, PHP for collecting form data:
$receive_email = $_POST["consentForEmail"];
echo "<li>$receive_email</li>"
Thank you!
Aucun commentaire:
Enregistrer un commentaire