fork download
  1. <?php
  2. /*
  3.  * spremi ovaj fajl kao process_contact.php i upload u public_html
  4.  * u form action stavi process_contact.php -> <form action="process_contact.php" ...
  5.  */
  6. if($_POST['submitButton'])
  7. {
  8. // email na koji ces primati poruke
  9. $reciever_email = "contact@gx-hosting.com";
  10. // email koji ce biti prikazan kao sender
  11. $sender_email = "noreply@gx-hosting.com";
  12. // subjekat koji ce prikazati
  13. $subject = "Contact Form";
  14. $fname = $_POST['Name'];
  15. $email = $_POST['Email'];
  16. $msg = $_POST['Message'];
  17. // ime se mora upisati i ne smije sadrzavati vise od 20 karaktera
  18. if(strlen(preg_replace('/\s+/u','',$fname)) != 0 && strlen($fname) < 20)
  19. {
  20. // validacija emaila
  21. if(preg_match('/^[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)+$/i', $email) && strlen($email) < 128)
  22. {
  23. // poruka se mora upisati i ne smije sadrzavati vise od 6k karaktera
  24. if(strlen(preg_replace('/\s+/u','',$msg)) != 0 && strlen($msg) < 6000)
  25. {
  26. $headers = 'MIME-Version: 1.0' . "\r\n";
  27. $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
  28. $headers .= 'From: '.$sender_email. "\r\n";
  29. $headers .= 'Reply-To: '.$sender_email. "\r\n";
  30. $headers .= 'X-Mailer: PHP/' . phpversion();
  31. mail($reciever_email, $subject, $msg, $headers);
  32. }
  33. else
  34. {
  35. echo "poruka predugacka/prekratka";
  36. }
  37. }
  38. else
  39. {
  40. echo "email nije validan";
  41. }
  42. }
  43. else
  44. {
  45. echo "upiĊĦi svoje pravo ime";
  46. }
  47. }
  48.  
Success #stdin #stdout 0.03s 13112KB
stdin
Standard input is empty
stdout
Standard output is empty