-2
こんにちは、私はPHPで新しいです、私は私のコードでいくつかの助けが必要です。チェックボックスの値を送信
問題:チェックボックスの値をチェックしてメールを送信したいが、できない。この問題を解決する方法がわからない。
ここに私のコードです。
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;
?>
私はそれを試してみましたが、送信をクリックすると、エラーメッセージが表示されます:引数が指定されていません! –
@MaxSadowski - これはチェックボックスとは関係ありません。それはPHPの中止の一番上にあるあなたのテストです。 – Quentin