Witam. Dostał mi się w ręce szablon, HTML+JS, w którym występuje formularz kontaktowy. Do formularza podpięty jest skrypt PHP (poniżej). W dokumentacji nie dostałem za wiele, proszę więc o pomoc tu - czy za pomocą takiego skryptu można cokolwiek wysłać? Wydaje mi się że sam e-mail do podmiany to za mało? Nie brakuje tu czegoś? Wyjaśni mi ktoś proszę, w kilku słowach co tu jest wykonywane?
<?php
function tommus_email_validate
($email) { return filter_var
($email, FILTER_VALIDATE_EMAIL
) && preg_match('/@.+\./', $email); }
$name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $comments = $_POST['comments'];
exit('<div class="error_message">Attention! You must enter your name.</div>');
} else if(trim($name) == 'Name *') {
exit('<div class="error_message">Attention! You must enter your name.</div>');
} else if(trim($email) == '') {
exit('<div class="error_message">Attention! Please enter a valid email address.</div>');
} else if(!tommus_email_validate($email)) {
exit('<div class="error_message">Attention! You have entered an invalid e-mail address.</div>');
} else if(trim($phone) == '') {
exit('<div class="error_message">Attention! Please enter a valid phone number.</div>');
exit('<div class="error_message">Attention! Phone number can only contain digits.</div>');
} else if(trim($comments) == 'Comment *') {
exit('<div class="error_message">Attention! Please enter your message.</div>');
} else if(trim($comments) == '') {
exit('<div class="error_message">Attention! Please enter your message.</div>');
$address = 'ADRES@EMAIL.XYZ';
$e_subject = 'You\'ve been contacted by ' . $name . '.';
$e_body = "You have been contacted by $name from your contact form, their additional message is as follows." . "\r\n" . "\r\n";
$e_content = "\"$comments\"" . "\r\n" . "\r\n";
$e_reply = "You can contact $name via email, $email or via phone $phone";
$msg = wordwrap( $e_body . $e_content . $e_reply, 70
);
$headers = "From: $email" . "\r\n";
$headers .= "Reply-To: $email" . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/plain; charset=utf-8" . "\r\n";
$headers .= "Content-Transfer-Encoding: quoted-printable" . "\r\n";
if(mail($address, $e_subject, $msg, $headers)) { echo "<fieldset><div id='success_page'><h4>Email Sent Successfully.</h4><p>Thank you $name, your message has been submitted to us.</p></div></fieldset>"; }