Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- session_start();
- //filtruje dane użytkownika
- $imie = htmlspecialchars(trim($_POST['imie']));
- $mail = htmlspecialchars(trim($_POST['mail']));
- $wiadomosc = htmlspecialchars(trim($_POST['wiadomosc']));
- $temat = 'Wiadomość ze story Glub.com';
- $send = $_POST['send'];
- //mail na który będa wysyłane wiadomości
- $odbiorca = "mojmail";
- //nagłówki
- $header = "\r\nOd: $mail";
- //Sprawdzam czy istnieje ciastko, jeżeli tak wyświetlam komunikat
- if (isset($_COOKIE['send'])) $error ='Wait '.($_COOKIE['send']-time()).' seconds before sending another message.';
- if ($send && !isset($_COOKIE['send']))
- {
- //Sprawdzam nick
- if (empty($imie))
- { $error = "You did not fill in the name field <br/>";
- }
- //Sprawdzam wiadomosc
- if (empty($wiadomosc))
- { $error .= "You have not entered a message field<br/>"; }
- elseif (strlen($wiadomosc) > 800)
- { $error .="Too long message. Max 800 characters<br/>";}
- //Sprawdzam czy są błędy i wysyłam wiadomość
- if (empty($error))
- {
- $list = "Przysłał - $imie ( $mail ) <br/> Treść wiadomości - $wiadomosc";
- if (mail($odbiorca, $temat, $list, $header))
- {
- $error .= "Message was sent. We will try to respond as quickly as possible.";
- setcookie("send", time()+60, time()+60);
- }
- else
- { $error .= "An error occurred while uploading the message, please try later.";}
- }
- }
- ob_end_clean();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement