I have added two checkboxes to a form which are set to be mailed to an email address on send. Sounds great, only it is not processing the form. Everything was processing great until I added the checkboxes-
Here is the HTML:
<form id="form" method="post" name="validation" action="index.php" onsubmit="received()">
<fieldset>
<label for="name">Full Name:</label>
<input type="text" name="name" title="Enter your name">
<label for="attending"># Attending:</label>
<input style="margin-left:190px;" type="text" name="attending" title="Optional">
<label for="guests">Name of Guest(s): </label>
<input style="margin-left:370px;" type="text" name="guests">
<span class="fakelabel">Please Check All that Apply:</span>
<input type="checkbox" name="prenuptial" value="Yes"><span class="additions">I Will Be Attending the Prenuptial Dinner</span><br>
<input type="checkbox" name="transportation" value="Yes"><span class="additions">I Will Be Requiring Transportation To and From the Wedding</span>
<div class="submitcontainer">
<input type="submit" style="font-size:0;" name="submit" class="submitbutton" id="submit">
</fieldset>
</form>
Process (I cut a lot out leaving only the newly added areas-)
$name = strip_tags($_POST['name']);
$attending = strip_tags($_POST['attending']);
$guests = strip_tags($_POST['guests']);
$prenuptial = strip_tags($_POST['prenuptial'] == 'Yes');
$transportation = strip_tags($_POST['transportation'] == 'Yes');
$to = 'email@yahoo.com';
// Send Message
mail($email, "RE: Wedding RSVP", $intro, $headers);
mail($to, "Wedding RSVP", "Name: {$name}\n Attending: {$attending}\n Guests: {$guests}\n Prenuptial: {$prenuptial}\n Transportation: {$transportation}\n");
?>
I’m wondering if the error is in the last line here?
Why
strip_tags?Do this, Below code will check whether you have selected checkbox or not. If you have checked, it send
YeselseNo. Change textNoto null if you don’t want to sent.See You have given value is
yesin both the checkbox, So when you post a foryeswill be the value of both the checkbox.If you want any other value you can put it. And you can check using
issetEg – you can add it like this
And in php write like this