I have a form like this:
<form name="AddUser" method="post" action="createUser.php">
<fieldset>
<legend>Add a user </legend>
<label for="name">Name</label>
<input type="text" name="name" id="name" value="" />
<br/>
<label for="newsletter">Subscribe to newsletter:</label>
<input type="checkbox" name="newsletter" id=" newsletter " value="" />
<br/>
<input type="submit" name="add_user_btn" value="Create" />
</fieldset>
</form>
As usually the solution is simple, using isset() method:
if(isset($_POST['newsletter'])) $newsletter= 1; else $newsletter= 0;
No comments:
Post a Comment