13-04-2012, 15:12
Kod:
<?php
$field_name = $_POST['cf_name'];
$field_subject = $_POST['cf_subject'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
if (empty($field_name) || empty($field_subject) || empty($field_email) || empty($field_message)) {
?>
<script language="javascript" type="text/javascript">
alert('Proszę wypełnić wszystkie pola');
window.location = 'kontakt.html';
</script>
<?php
} else {
$mail_to = '[email protected]';
$subject = 'Zapytanie od: '.$field_name;
$body_message .= 'Od: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Temat: '.$field_subject."\n";
$body_message .= 'Tre¶ć: '.$field_message;
$headers = 'Od: '.$cf_email."\r\n";
$headers .= 'Odpowiedz do: '.$cf_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) {
?>
<script language="javascript" type="text/javascript">
alert('Dziękuje za wysłanie zapytania. Odezwiemy się najszybciej jak to możliwe');
window.location = 'index.html';
</script>
<?php
} else {
?>
<script language="javascript" type="text/javascript">
alert('Wysłanie wiadomo¶ci nie powiodło sie. Wy¶lij wiadomo¶ć ręcznie na adres: [email protected]');
window.location = 'kontakt.html';
</script>
<?php
}
}
?>