Kod: Zaznacz cały
<?php $header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/plain; charset=utf-8' . "\r\n"; $header .= 'From: lukas@lukastransport.cba.pl' . "\r\n";
$to = 'lukas@transport.cba.pl';
$subject = 'www.lukastransport.cba.pl';
$contact_submitted = 'Twoja wiadomosc zostala wyslana.';
// Do not amend anything below here, unless you know PHP
function email_is_valid($email) {
return preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i',$email);
}
if (!email_is_valid($to)) {
echo '<p style="color: red;">You must set-up a valid (to) email address before this contact page will work.</p>';
}
if (isset($_POST['submit'])) {
$return = "\r";
$youremail = trim(htmlspecialchars($_POST['email']));
$yourname = stripslashes(strip_tags($_POST['name']));
$yourmessage = stripslashes(strip_tags($_POST['message']));
$contact_name = "Name: ".$yourname;
$message_text = "Message: ".$yourmessage;
$user_answer = trim(htmlspecialchars($_POST['user_answer']));
$answer = trim(htmlspecialchars($_POST['answer']));
$message = $contact_name . $return . $message_text;
$headers = "From: ".$youremail;
if (email_is_valid($youremail) && !eregi("\r",$youremail) && !eregi("\n",$youremail) && $yourname != "" && $yourmessage != "" && substr(md5($user_answer),5,10) === $answer) {
mail($to,$subject,$message,$header,$headers);
$yourname = '';
$youremail = '';
$yourmessage = '';
echo '<p style="color: blue;">'.$contact_submitted.'</p>';
}
else echo '<p style="color: red;">Please enter your name, a valid email address, your message and the answer to the simple maths question before sending your message.</p>';
}
$number_1 = rand(1, 9);
$number_2 = rand(1, 9);
$answer = substr(md5($number_1+$number_2),5,10); include ('email.html');
?>