Advertisement
Guest User

Untitled

a guest
Jun 24th, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.35 KB | None | 0 0
  1. <?php
  2. // первая форма
  3. if (isset ($_POST['contactFF'])) {
  4.   $to = "name@yandex.ru"; // поменять на свой адрес
  5.   $from = $_POST['contactFF'];
  6.   $subject = "Заполнена контактная форма с ".$_SERVER['HTTP_REFERER'];
  7.   $message = "Имя: ".$_POST['nameFF']."\nEmail: ".$from."\nIP: ".$_SERVER['REMOTE_ADDR']."\nСообщение: ".$_POST['messageFF'];
  8.   $boundary = md5(date('r', time()));
  9.   $filesize = '';
  10.   $headers = "MIME-Version: 1.0\r\n";
  11.   $headers .= "From: " . $from . "\r\n";
  12.   $headers .= "Reply-To: " . $from . "\r\n";
  13.   $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
  14.   $message="
  15. Content-Type: multipart/mixed; boundary=\"$boundary\"
  16.  
  17. --$boundary
  18. Content-Type: text/plain; charset=\"utf-8\"
  19. Content-Transfer-Encoding: 7bit
  20.  
  21. $message";
  22.   for($i=0;$i<count($_FILES['fileFF']['name']);$i++) {
  23.       if(is_uploaded_file($_FILES['fileFF']['tmp_name'][$i])) {
  24.          $attachment = chunk_split(base64_encode(file_get_contents($_FILES['fileFF']['tmp_name'][$i])));
  25.          $filename = $_FILES['fileFF']['name'][$i];
  26.          $filetype = $_FILES['fileFF']['type'][$i];
  27.          $filesize += $_FILES['fileFF']['size'][$i];
  28.          $message.="
  29.  
  30. --$boundary
  31. Content-Type: \"$filetype\"; name=\"$filename\"
  32. Content-Transfer-Encoding: base64
  33. Content-Disposition: attachment; filename=\"$filename\"
  34.  
  35. $attachment";
  36.      }
  37.    }
  38.    $message.="
  39. --$boundary--";
  40.  
  41.   if ($filesize < 10000000) { // проверка на общий размер всех файлов. Многие почтовые сервисы не принимают вложения больше 10 МБ
  42.     mail($to, $subject, $message, $headers);
  43.     $output = '<script>alert("Ваше сообщение получено, спасибо!");</script>';
  44.   } else {
  45.     $output = '<script>alert("Извините, письмо не отправлено. Размер всех файлов превышает 10 МБ.");</script>';
  46.   }
  47. }
  48.  
  49. // вторая форма
  50. if (isset ($_POST['contactFF2'])) {
  51.   $to = "name@yandex.ru"; // поменять на свой адрес
  52.   $from = $_POST['contactFF2'];
  53.   $subject = "Заполнена контактная форма с ".$_SERVER['HTTP_REFERER'];
  54.   $message = "Имя: ".$_POST['nameFF2']."\nEmail: ".$from."\nIP: ".$_SERVER['REMOTE_ADDR']."\nСообщение: ".$_POST['messageFF2'];
  55.   $boundary = md5(date('r', time()));
  56.   $filesize = '';
  57.   $headers = "MIME-Version: 1.0\r\n";
  58.   $headers .= "From: " . $from . "\r\n";
  59.   $headers .= "Reply-To: " . $from . "\r\n";
  60.   $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
  61.   $message="
  62. Content-Type: multipart/mixed; boundary=\"$boundary\"
  63.  
  64. --$boundary
  65. Content-Type: text/plain; charset=\"utf-8\"
  66. Content-Transfer-Encoding: 7bit
  67.  
  68. $message";
  69.   for($i=0;$i<count($_FILES['fileFF2']['name']);$i++) {
  70.       if(is_uploaded_file($_FILES['fileFF2']['tmp_name'][$i])) {
  71.          $attachment = chunk_split(base64_encode(file_get_contents($_FILES['fileFF2']['tmp_name'][$i])));
  72.          $filename = $_FILES['fileFF2']['name'][$i];
  73.          $filetype = $_FILES['fileFF2']['type'][$i];
  74.          $filesize += $_FILES['fileFF2']['size'][$i];
  75.          $message.="
  76.  
  77. --$boundary
  78. Content-Type: \"$filetype\"; name=\"$filename\"
  79. Content-Transfer-Encoding: base64
  80. Content-Disposition: attachment; filename=\"$filename\"
  81.  
  82. $attachment";
  83.      }
  84.    }
  85.    $message.="
  86. --$boundary--";
  87.  
  88.   if ($filesize < 10000000) { // проверка на общий размер всех файлов. Многие почтовые сервисы не принимают вложения больше 10 МБ
  89.     mail($to, $subject, $message, $headers);
  90.     $output = '<script>alert("Ваше сообщение получено, спасибо!");</script>';
  91.   } else {
  92.     $output = '<script>alert("Извините, письмо не отправлено. Размер всех файлов превышает 10 МБ.");</script>';
  93.   }
  94. }
  95.  
  96. // третья форма
  97. if (isset ($_POST['contactFF3'])) {
  98.   $to = "name@yandex.ru"; // поменять на свой адрес
  99.   $from = $_POST['contactFF3'];
  100.   $subject = "Заполнена контактная форма с ".$_SERVER['HTTP_REFERER'];
  101.   $message = "Имя: ".$_POST['nameFF3']."\nEmail: ".$from."\nIP: ".$_SERVER['REMOTE_ADDR']."\nСообщение: ".$_POST['messageFF3'];
  102.   $boundary = md5(date('r', time()));
  103.   $filesize = '';
  104.   $headers = "MIME-Version: 1.0\r\n";
  105.   $headers .= "From: " . $from . "\r\n";
  106.   $headers .= "Reply-To: " . $from . "\r\n";
  107.   $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
  108.   $message="
  109. Content-Type: multipart/mixed; boundary=\"$boundary\"
  110.  
  111. --$boundary
  112. Content-Type: text/plain; charset=\"utf-8\"
  113. Content-Transfer-Encoding: 7bit
  114.  
  115. $message";
  116.   for($i=0;$i<count($_FILES['fileFF3']['name']);$i++) {
  117.       if(is_uploaded_file($_FILES['fileFF3']['tmp_name'][$i])) {
  118.          $attachment = chunk_split(base64_encode(file_get_contents($_FILES['fileFF3']['tmp_name'][$i])));
  119.          $filename = $_FILES['fileFF3']['name'][$i];
  120.          $filetype = $_FILES['fileFF3']['type'][$i];
  121.          $filesize += $_FILES['fileFF3']['size'][$i];
  122.          $message.="
  123.  
  124. --$boundary
  125. Content-Type: \"$filetype\"; name=\"$filename\"
  126. Content-Transfer-Encoding: base64
  127. Content-Disposition: attachment; filename=\"$filename\"
  128.  
  129. $attachment";
  130.      }
  131.    }
  132.    $message.="
  133. --$boundary--";
  134.  
  135.   if ($filesize < 10000000) { // проверка на общий размер всех файлов. Многие почтовые сервисы не принимают вложения больше 10 МБ
  136.     mail($to, $subject, $message, $headers);
  137.     $output = '<script>alert("Ваше сообщение получено, спасибо!");</script>';
  138.   } else {
  139.     $output = '<script>alert("Извините, письмо не отправлено. Размер всех файлов превышает 10 МБ.");</script>';
  140.   }
  141. }
  142. ?>
  143.  
  144.  
  145. <!DOCTYPE HTML>
  146.  
  147. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  148. <title>Контактная форма</title>
  149. <style>
  150. .feedback-form { /* вся форма */
  151.   max-width: 550px;
  152.   padding: 2%;
  153.   border-radius: 3px;
  154.   background: #f1f1f1;
  155. }
  156. .feedback-form label { /* наименование полей */
  157.   float: left;
  158.   display: block;
  159.   clear: right;
  160. }
  161. .feedback-form .w100 { /* поля */
  162.   float: right;
  163.   max-width: 400px;
  164.   width: 97%;
  165.   margin-bottom: 1em;
  166.   padding: 1.5%;
  167. }
  168. .feedback-form .border { /* граница полей */
  169.   border-radius: 1px;
  170.   border-width: 1px;
  171.   border-style: solid;
  172.   border-color: #C0C0C0 #D9D9D9 #D9D9D9;
  173.   box-shadow: 0 1px 1px rgba(255,255,255,.5), 0 1px 1px rgba(0,0,0,.1) inset;
  174. }
  175. .feedback-form .border:focus {
  176.   outline: none;
  177.   border-color: #abd9f1 #bfe3f7 #bfe3f7;
  178. }
  179. .feedback-form .border:hover {
  180.   border-color: #7eb4ea #97cdea #97cdea;
  181. }
  182. .feedback-form .border:focus::-moz-placeholder { /* убрать при фокусе первоначальный текст поля */
  183.   color: transparent;
  184. }
  185. .feedback-form .border:focus::-webkit-input-placeholder {
  186.   color: transparent;
  187. }
  188. .feedback-form .border:not(:focus):not(:hover):valid { /* правильно заполненные поля */
  189.   opacity: .8;
  190. }
  191. .submitFF { /* кнопка "Отправить" */
  192.   padding: 2%;
  193.   border: none;
  194.   border-radius: 3px;
  195.   box-shadow: 0 0 0 1px rgba(0,0,0,.2) inset;
  196.   background: #669acc;
  197.   color: #fff;
  198. }
  199. .feedback-form br {
  200.   height: 0;
  201.   clear: both;
  202. }
  203. .submitFF:hover {
  204.   background: #5c90c2;
  205. }
  206. .submitFF:focus {
  207.   box-shadow: 0 1px 1px #fff, inset 0 1px 2px rgba(0,0,0,.8), inset 0 -1px 0 rgba(0,0,0,.05);
  208. }
  209. </style>
  210.  
  211. <?php
  212.     if (!empty($output)) {
  213.         echo $output;
  214.     }
  215. ?>
  216. <form enctype="multipart/form-data" method="post" class="feedback-form">
  217. <label for="nameFF">Имя:</label>
  218. <input type="text" name="nameFF" id="nameFF" required placeholder="например, Иван Иванович Иванов" x-autocompletetype="name" class="w100 border">
  219. <label for="contactFF">Email:</label>
  220. <input type="email" name="contactFF" id="contactFF" required placeholder="например, ivan@yandex.ru" x-autocompletetype="email" class="w100 border">
  221. <label for="fileFF">Прикрепить файл:</label>
  222. <input type="file" name="fileFF[]" multiple id="fileFF" class="w100">
  223. <label for="messageFF">Сообщение:</label>
  224. <textarea name="messageFF" id="messageFF" required rows="5" placeholder="Детали заявки…" class="w100 border"></textarea>
  225. <br>
  226. <input value="Отправить" type="submit" class="submitFF">
  227. </form>
  228.  
  229. <form enctype="multipart/form-data" method="post" class="feedback-form">
  230. <label for="nameFF2">Имя:</label>
  231. <input type="text" name="nameFF2" id="nameFF2" required placeholder="например, Иван Иванович Иванов" x-autocompletetype="name" class="w100 border">
  232. <label for="contactFF2">Email:</label>
  233. <input type="email" name="contactFF2" id="contactFF2" required placeholder="например, ivan@yandex.ru" x-autocompletetype="email" class="w100 border">
  234. <label for="fileFF2">Прикрепить файл:</label>
  235. <input type="file" name="fileFF2[]" multiple id="fileFF2" class="w100">
  236. <label for="messageFF2">Сообщение:</label>
  237. <textarea name="messageFF2" id="messageFF2" required rows="5" placeholder="Детали заявки…" class="w100 border"></textarea>
  238. <br>
  239. <input value="Отправить" type="submit" class="submitFF">
  240. </form>
  241.  
  242. <form enctype="multipart/form-data" method="post" class="feedback-form">
  243. <label for="nameFF3">Имя:</label>
  244. <input type="text" name="nameFF3" id="nameFF3" required placeholder="например, Иван Иванович Иванов" x-autocompletetype="name" class="w100 border">
  245. <label for="contactFF3">Email:</label>
  246. <input type="email" name="contactFF3" id="contactFF3" required placeholder="например, ivan@yandex.ru" x-autocompletetype="email" class="w100 border">
  247. <label for="fileFF3">Прикрепить файл:</label>
  248. <input type="file" name="fileFF3[]" multiple id="fileFF3" class="w100">
  249. <label for="messageFF3">Сообщение:</label>
  250. <textarea name="messageFF3" id="messageFF3" required rows="5" placeholder="Детали заявки…" class="w100 border"></textarea>
  251. <br>
  252. <input value="Отправить" type="submit" class="submitFF">
  253. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement