Hallo ich bin neu bei PHP und ich brauche Hilfe mit meinem Code.Send checkbox value
Das Problem: Ich möchte eine Mail mit Checkbox-Werten senden, wenn sie überprüft werden, aber ich kann nicht, und ich weiß nicht, wie Sie dieses Problem lösen.
Hier ist mein Code.
HTML
<div class="form-group">
<label for="jours">Choix des jours de travail</label>
<label class="checkbox">
<input type="checkbox" name="time[]"value="Lundi"> Lundi
</label>
<label class="checkbox">
<input type="checkbox" name="time[]"value="Mardi"> Mardi
</label>
<label class="checkbox">
<input type="checkbox" name="time[]"value="Mercredi"> Mercredi
</label>
<label class="checkbox">
<input type="checkbox" name="time[]"value="Jeudi"> Jeudi
</label>
<label class="checkbox">
<input type="checkbox" name="time[]"value="Vendredi"> Vendredi
</label>
<label class="checkbox">
<input type="checkbox" name="time[]"value="Samedi"> Samedi
</label>
</div>
PHP
<?php
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = strip_tags(htmlspecialchars($_POST['name']));
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$phone = strip_tags(htmlspecialchars($_POST['phone']));
$message = strip_tags(htmlspecialchars($_POST['message']));
// Create the email and send the message
$to = '[email protected]'; // Add your email address inbetween the '' replacing [email protected] - This is where the form will send a message to.
$email_subject = "Website Contact Form: $name";
$email_body = "Vous avez recu un nouveau message\n\n"."Voici les détails:\n\nName: $name\n\nEmail: $email_address\n
\nPhone: $phone\n\nMessage:\n$message\n\nThe client want help in these days: $time\n";
$headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
Ich versuche es, aber nach dem Klicken auf senden bekomme ich Fehlermeldung: Keine Argumente zur Verfügung gestellt! –
@MaxSadowski - Nun, das hat nichts mit den Checkboxen zu tun. Das ist dein Test am Anfang des PHP-Abbruchs. – Quentin