Advertisement
Guest User

Untitled

a guest
Aug 30th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. session_start();
  4.  
  5. //filtruje dane użytkownika
  6. $imie = htmlspecialchars(trim($_POST['imie']));
  7. $mail = htmlspecialchars(trim($_POST['mail']));
  8. $wiadomosc = htmlspecialchars(trim($_POST['wiadomosc']));
  9. $temat = 'Wiadomość ze story Glub.com';
  10. $send = $_POST['send'];
  11. //mail na który będa wysyłane wiadomości
  12. $odbiorca = "mojmail";
  13. //nagłówki
  14. $header = "\r\nOd: $mail";
  15.  
  16. //Sprawdzam czy istnieje ciastko, jeżeli tak wyświetlam komunikat
  17. if (isset($_COOKIE['send'])) $error ='Wait '.($_COOKIE['send']-time()).' seconds before sending another message.';
  18.  
  19. if ($send && !isset($_COOKIE['send']))
  20. {
  21. //Sprawdzam nick
  22. if (empty($imie))
  23. { $error = "You did not fill in the name field <br/>";
  24. }
  25.  
  26.  
  27. //Sprawdzam wiadomosc
  28. if (empty($wiadomosc))
  29. { $error .= "You have not entered a message field<br/>"; }
  30. elseif (strlen($wiadomosc) > 800)
  31. { $error .="Too long message. Max 800 characters<br/>";}
  32.  
  33. //Sprawdzam czy są błędy i wysyłam wiadomość
  34. if (empty($error))
  35. {
  36. $list = "Przysłał - $imie ( $mail ) <br/> Treść wiadomości - $wiadomosc";
  37.  
  38. if (mail($odbiorca, $temat, $list, $header))
  39. {
  40. $error .= "Message was sent. We will try to respond as quickly as possible.";
  41. setcookie("send", time()+60, time()+60);
  42. }
  43. else
  44. { $error .= "An error occurred while uploading the message, please try later.";}
  45. }
  46. }
  47. ob_end_clean();
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement