fork download
  1. <?php
  2.  
  3. define("CONTACT_FORM", 'pidor@mail.ru');
  4.  
  5. function ValidateEmail($value){
  6. $regex = '/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i';
  7.  
  8. if($value == '') {
  9. return false;
  10. } else {
  11. $string = preg_replace($regex, '', $value);
  12. }
  13.  
  14. return empty($string) ? true : false;
  15. }
  16.  
  17. $post = (!empty($_POST)) ? true : false;
  18.  
  19. if($post){
  20.  
  21. $name = stripslashes($_POST['name']);
  22. $phone = stripslashes($_POST['phone']);
  23. $email = stripslashes($_POST['email']);
  24. $subject = 'Заявка';
  25. $error = '';
  26. $message = '
  27. <html>
  28. <head>
  29. <title>Заявка</title>
  30. </head>
  31. <body>
  32. <p>Имя: '.$name.'</p>
  33. <p>Телефон : '.$phone.'</p>
  34. <p>Email : '.$email.'</p>
  35. </body>
  36. </html>';
  37.  
  38. if (!ValidateEmail($email)){
  39. $error = 'Email введен неправильно!';
  40. }
  41.  
  42. if(!$error){
  43. $mail = mail(CONTACT_FORM, $subject, $message,
  44. "From: ".$name." <".$email.">\r\n"
  45. ."Reply-To: ".$email."\r\n"
  46. ."Content-type: text/html; charset=utf-8 \r\n"
  47. ."X-Mailer: PHP/" . phpversion());
  48.  
  49. if($mail){
  50. echo 'OK';
  51. }
  52. }else{
  53. echo '<div class="bg-danger">'.$error.'</div>';
  54. }
  55.  
  56. }
  57. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Standard output is empty