mercredi 10 avril 2019

Checkboxes in Php Form

I've made a form that has a series of checkboxes, i'm trying to get them to post the results in an email but they aren't showing up, html is:

<input class="basic-config" type="checkbox" name="ch[]" id="basic-option1" value="200">  
<label for="basic-option1"> option 1 <span class="right-align">$200</span></label>

<input class="basic-config" type="checkbox" name="ch[]" id="basic-option2" value="500">  
<label for="basic-option2"> option 2<span class="right-align">$500</span></label>

php is:

<?php

if (isset($_POST['submit'])) {

$name = $_POST ['name'];
$mailFrom = $_POST ['mail'];
$website = $_POST ['website'];
$comments = $_POST ['comments'];
$basicAmount = $_POST ['basic-amount'];
$extras = "None";
if(isset($_POST["ch"]))
$extras = implode(", ", $_POST["ch"]);

$mailTo = "josh@myemail.com";
$headers = "From: ".$mailFrom; 
$txt = "\n
Basic Order Request. \n\n
From: $name \n\n
Email: $mailFrom \n\n
Website: $website \n\n
Comments: $comments \n\n
Extras: $extras \n\n
Total: $basicAmount";

In the email I get the line "Extras: None" even when I click both options on the site, I know they are linked properly because the total amount shows up correctly, just need to see which options are selected also. Can anyone let me know what I've done wrong here?




Aucun commentaire:

Enregistrer un commentaire