Przygotowałem formularz do wysyłania zapytań - formularz.html. Korzystam z PHPmailer'a do wysyłania maili, a do walidacji skryptu jQuery.validationEngine. Wszystko działa poprawnie, ale po wywołaniu strony moja.strona/send.php zostaje wysłany mail z pustymi polami. Chciałbym tego uniknąć i "zablokować" taką możliwość. Proszę o pomoc w modyfikacji skryptu.
formularz.html
<script type="text/javascript"> jQuery(document).ready( function() {
jQuery("#formID").validationEngine();
});
<form id="formID" class="formular" method="post" action="send.php"> <input value="" class="validate[required] text-input" type="text" name="name" id="name" /> <input value="" class="validate[required,custom[email]] text-input" type="text" name="email" id="email" /> <input value="" class="validate[required,custom[phone]] text-input" type="text" name="phone" id="phone" /> <input value="" class="text-input" type="text" name="company" id="company" /> <input value="" class="validate[required] text-input" type="text" name="city" id="city" /> <input value="" class="validate[required] text-input" type="text" name="postcode" id="postcode" /> <div class="infos">Proszę wpisać treść zapytania
</div> <textarea class="validate[required] text-input" name="comment" id="comment" rows="10" cols="57"></textarea> <div class="infos">Wyrażam zgodę ...
</div> <input class="validate[required] checkbox" type="checkbox" id="agree" name="agree" value="TAK"/> <div class="infos">Zgadzam się na otrzymywanie....
</div> <input class="checkbox" type="checkbox" id="newsletter" name="newsletter" value="TAK"/> <input class="submit" type="submit" value="Sprwadź i wyślij zapytanie!"/>
send.php <?php
require("forms/phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsMail();
$mail->IsHTML(true);
$mail->ContentType = 'text/html';
$mail->CharSet = 'utf-8';
$mail->Encoding = '8bit';
$mail->AddAddress("xx@xx");
$mail->Subject = "Zapytanie WWW";
$mail->FromName = ($_POST['name']);
$mail->From = ($_POST['email']);
$plik=fopen("forms/zap_www_l.txt", "r"); $licznik++;
$plik=fopen("forms/zap_www_l.txt", "w"); $text_body = 'Zapytanie nr: <strong>WWW/'.date("d/m/Y").'/'.$licznik.'</strong><br /><br />'; $text_body .= 'Imię i nazwisko: <strong>'.$_POST['name'].'</strong><br />';
$text_body .= 'Nazwa firmy: <strong>'.$_POST['company'].'</strong><br />';
$text_body .= 'E-mail: <strong>'.$_POST['email'].'</strong><br />';
$text_body .= 'Telefon: <strong>'.$_POST['phone'].'</strong><br />';
$text_body .= 'Miasto: <strong>'.$_POST['city'].'</strong><br />';
$text_body .= 'Kod pocztowy: <strong>'.$_POST['postcode'].'</strong><br />';
$text_body .= 'Treść zapytania:<br /><strong>'.$_POST['comment'].'</strong><br /><br />';
$text_body .= 'Wyrażam zgodę... <br />- <strong>'.$_POST['agree'].'</strong> -<br /><br />';
$text_body .= 'Zgadzam się...<br />- <strong>'.$_POST['newsletter'].'</strong> -<br /><br />';
$text_body .= 'IP: '.$_SERVER['REMOTE_ADDR'].'<br />';
$mail->Body = $text_body;
if(!$mail->Send())
{
echo "Error sending: " . $mail->ErrorInfo;; }
else
{
echo "Zapytanie zostało wysłane"; }
?>