私の連絡フォームから空メールがたくさん届いています。それはそれを検証しているので、私はこれがどのように可能かわかりません。 SO誰かにここ確認済みのフォームで空のメールを受信
<?php
// configure
$from = 'myemail';
$sendTo = 'myemail';
$senderNaam = $_POST['naam'];
$senderEmail = $_POST['email'];
$subject = 'Contact';
$okMessage = '<p>Send succesfully!</p>';
$errorMessage = '<p>Error!</p>';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-Type: text/html; charset=utf-8" . "\r\n";
$headers .= "From: ". $from. "\r\n";
$headers .= 'Reply-To: '. $senderNaam." <".$senderEmail.">\r\n";
// let's do the sending
try
{
$emailText = "New message\n=============================\n";
$emailText = "<table>
<tr><td style='padding-left: 10px; padding-right: 10px; background: #eee;'>Naam:</td><td style='padding-left: 10px; font-weight: bold;'>".$_POST['titel']." ".$_POST['naam']."</td></tr>
<tr><td style='padding-left: 10px; padding-right: 10px; background: #eee;'>Bedrijfsnaam:</td><td style='padding-left: 10px; font-weight: bold;'>".$_POST['bedrijfsnaam']."</td></tr>
<tr><td style='padding-left: 10px; padding-right: 10px; background: #eee;'>Adres:</td><td style='padding-left: 10px; font-weight: bold;'>".$_POST['straat']." ".$_POST['huisnummer']." ".$_POST['toevoeging']."</td></tr>
<tr><td style='padding-left: 10px; padding-right: 10px; background: #eee;'>Postcode:</td><td style='padding-left: 10px; font-weight: bold;'>".$_POST['postcode']." ".$_POST['letters']."</td></tr>
<tr><td style='padding-left: 10px; padding-right: 10px; background: #eee;'>Woonplaats:</td><td style='padding-left: 10px; font-weight: bold;'>".$_POST['woonplaats']."</td></tr>
<tr><td style='padding-left: 10px; padding-right: 10px; background: #eee;'>Telefoonnummer:</td><td style='padding-left: 10px; font-weight: bold;'>".$_POST['kengetal']." ".$_POST['telefoon']."</td></tr>
<tr><td style='padding-left: 10px; padding-right: 10px; background: #eee;'>E-mailadres:</td><td style='padding-left: 10px; font-weight: bold;'>".$_POST['email']."</td></tr>
<tr><td style='padding-left: 10px; padding-right: 10px; background: #eee;'>Bericht:</td><td style='padding-left: 10px; font-weight: bold;'>".$_POST['bericht']."</td></tr>
</table>";
mail($sendTo, $subject, $emailText, $headers);
$responseArray = array('type' => 'success', 'message' => $okMessage);
}
catch (\Exception $e)
{
$responseArray = array('type' => 'danger', 'message' => $errorMessage);
}
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$encoded = json_encode($responseArray);
header('Content-Type: application/json');
echo $encoded;
}
else {
echo $responseArray['message'];
}
?>
ポストから:これは私の検証(contact.php)である
<form id="contact-form" method="post" action="contact.php" role="form">
<div class="messages"></div>
<div class="controls">
<div class="row">
<div class="col-xs-10">
<div class="form-group">
<label>Aanhef *</label>
<div class="label-group">
<label class="radio-inline"><input class="radio" type="radio" required="required" value="Dhr." name="titel">Dhr.</label>
<label class="radio-inline"><input class="radio" type="radio" required="required" value="Mevr." name="titel">Mevr.</label>
<div class="help-block with-errors"></div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="form_email">E-mail adres *</label>
<input id="form_email" type="email" name="email" class="form-control" pattern="^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,})$" placeholder="Uw e-mailadres *" required="required" data-error="Uw e-mailadres (zonder spaties!)">
<div class="help-block with-errors"></div>
</div>
</div>
</div>
</div>
</form>
:
この
は私のフォームである(のみ指示を与えるために1行を与えました) 「あなたはアクションURLがPOSTデータなしでブラウザから直接アクセスできると思ったことがありますか?そうすれば、すべての「フィールド」が空になります。これは問題の可能性がありますが、これを解決する方法はわかりません。私のメールボックスは完全なLOLを実行しているので、誰かがアイデアを持っていますか?
EDIT 1:さてさて、私はこの試みた:。
// add all your other fields here
if (!isset($_POST['naam']) || !isset($_POST['email'])) {
mail($sendTo, $subject, $emailText, $headers);
}
$responseArray = array('type' => 'success', 'message' => $okMessage);
しかし、誰結果は、まだ "フォームが正常に送信" :(言う私のブラウザでcontact.phpを開くことができませんが
誰でも私を助けてくれますか? – Jorus