mercredi 23 juin 2021

Checkboxes in Form return only 1 (last selected) value

I have 3 checkboxes. If i select more than 1, it mails me only the last selected. (example: Red, Blue, Green, all selected. In my email i receive only Green. Rest of the fields work fine.

Here's my checkbox :

<label>
    Which color do you like?<br />
    <label>
    <input class="filled-in" type="checkbox" name="checkbox1" value="Red" /><span>Red</span><br />
    </label>
    <label>
    <input class="filled-in" type="checkbox" name="checkbox1" value="Blue" /><span>Blue</span><br />
    </label>
    <label>
    <input class="filled-in" type="checkbox" name="checkbox1" value="Green" /><span>Green</span><br />
    </label>
</p>

In my form-mailer.php i have:

$email_address = $_REQUEST['email_address'] ;
$comments = $_REQUEST['comments'] ;
$first_name = $_REQUEST['first_name'] ;
$checkbox = $_POST['checkbox1'];
$msg = 
"First Name: " . $first_name . "\r\n" . 
"Email: " . $email_address . "\r\n" . 
"Checkbox" . $checkbox . "\r\n" . 
"Comments: " . $comments ;

I'm missing something but because i'm a bad programmer i don't see what. Any Suggestions?




Aucun commentaire:

Enregistrer un commentaire