Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // первая форма
- if (isset ($_POST['contactFF'])) {
- $to = "name@yandex.ru"; // поменять на свой адрес
- $from = $_POST['contactFF'];
- $subject = "Заполнена контактная форма с ".$_SERVER['HTTP_REFERER'];
- $message = "Имя: ".$_POST['nameFF']."\nEmail: ".$from."\nIP: ".$_SERVER['REMOTE_ADDR']."\nСообщение: ".$_POST['messageFF'];
- $boundary = md5(date('r', time()));
- $filesize = '';
- $headers = "MIME-Version: 1.0\r\n";
- $headers .= "From: " . $from . "\r\n";
- $headers .= "Reply-To: " . $from . "\r\n";
- $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
- $message="
- Content-Type: multipart/mixed; boundary=\"$boundary\"
- --$boundary
- Content-Type: text/plain; charset=\"utf-8\"
- Content-Transfer-Encoding: 7bit
- $message";
- for($i=0;$i<count($_FILES['fileFF']['name']);$i++) {
- if(is_uploaded_file($_FILES['fileFF']['tmp_name'][$i])) {
- $attachment = chunk_split(base64_encode(file_get_contents($_FILES['fileFF']['tmp_name'][$i])));
- $filename = $_FILES['fileFF']['name'][$i];
- $filetype = $_FILES['fileFF']['type'][$i];
- $filesize += $_FILES['fileFF']['size'][$i];
- $message.="
- --$boundary
- Content-Type: \"$filetype\"; name=\"$filename\"
- Content-Transfer-Encoding: base64
- Content-Disposition: attachment; filename=\"$filename\"
- $attachment";
- }
- }
- $message.="
- --$boundary--";
- if ($filesize < 10000000) { // проверка на общий размер всех файлов. Многие почтовые сервисы не принимают вложения больше 10 МБ
- mail($to, $subject, $message, $headers);
- $output = '<script>alert("Ваше сообщение получено, спасибо!");</script>';
- } else {
- $output = '<script>alert("Извините, письмо не отправлено. Размер всех файлов превышает 10 МБ.");</script>';
- }
- }
- // вторая форма
- if (isset ($_POST['contactFF2'])) {
- $to = "name@yandex.ru"; // поменять на свой адрес
- $from = $_POST['contactFF2'];
- $subject = "Заполнена контактная форма с ".$_SERVER['HTTP_REFERER'];
- $message = "Имя: ".$_POST['nameFF2']."\nEmail: ".$from."\nIP: ".$_SERVER['REMOTE_ADDR']."\nСообщение: ".$_POST['messageFF2'];
- $boundary = md5(date('r', time()));
- $filesize = '';
- $headers = "MIME-Version: 1.0\r\n";
- $headers .= "From: " . $from . "\r\n";
- $headers .= "Reply-To: " . $from . "\r\n";
- $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
- $message="
- Content-Type: multipart/mixed; boundary=\"$boundary\"
- --$boundary
- Content-Type: text/plain; charset=\"utf-8\"
- Content-Transfer-Encoding: 7bit
- $message";
- for($i=0;$i<count($_FILES['fileFF2']['name']);$i++) {
- if(is_uploaded_file($_FILES['fileFF2']['tmp_name'][$i])) {
- $attachment = chunk_split(base64_encode(file_get_contents($_FILES['fileFF2']['tmp_name'][$i])));
- $filename = $_FILES['fileFF2']['name'][$i];
- $filetype = $_FILES['fileFF2']['type'][$i];
- $filesize += $_FILES['fileFF2']['size'][$i];
- $message.="
- --$boundary
- Content-Type: \"$filetype\"; name=\"$filename\"
- Content-Transfer-Encoding: base64
- Content-Disposition: attachment; filename=\"$filename\"
- $attachment";
- }
- }
- $message.="
- --$boundary--";
- if ($filesize < 10000000) { // проверка на общий размер всех файлов. Многие почтовые сервисы не принимают вложения больше 10 МБ
- mail($to, $subject, $message, $headers);
- $output = '<script>alert("Ваше сообщение получено, спасибо!");</script>';
- } else {
- $output = '<script>alert("Извините, письмо не отправлено. Размер всех файлов превышает 10 МБ.");</script>';
- }
- }
- // третья форма
- if (isset ($_POST['contactFF3'])) {
- $to = "name@yandex.ru"; // поменять на свой адрес
- $from = $_POST['contactFF3'];
- $subject = "Заполнена контактная форма с ".$_SERVER['HTTP_REFERER'];
- $message = "Имя: ".$_POST['nameFF3']."\nEmail: ".$from."\nIP: ".$_SERVER['REMOTE_ADDR']."\nСообщение: ".$_POST['messageFF3'];
- $boundary = md5(date('r', time()));
- $filesize = '';
- $headers = "MIME-Version: 1.0\r\n";
- $headers .= "From: " . $from . "\r\n";
- $headers .= "Reply-To: " . $from . "\r\n";
- $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
- $message="
- Content-Type: multipart/mixed; boundary=\"$boundary\"
- --$boundary
- Content-Type: text/plain; charset=\"utf-8\"
- Content-Transfer-Encoding: 7bit
- $message";
- for($i=0;$i<count($_FILES['fileFF3']['name']);$i++) {
- if(is_uploaded_file($_FILES['fileFF3']['tmp_name'][$i])) {
- $attachment = chunk_split(base64_encode(file_get_contents($_FILES['fileFF3']['tmp_name'][$i])));
- $filename = $_FILES['fileFF3']['name'][$i];
- $filetype = $_FILES['fileFF3']['type'][$i];
- $filesize += $_FILES['fileFF3']['size'][$i];
- $message.="
- --$boundary
- Content-Type: \"$filetype\"; name=\"$filename\"
- Content-Transfer-Encoding: base64
- Content-Disposition: attachment; filename=\"$filename\"
- $attachment";
- }
- }
- $message.="
- --$boundary--";
- if ($filesize < 10000000) { // проверка на общий размер всех файлов. Многие почтовые сервисы не принимают вложения больше 10 МБ
- mail($to, $subject, $message, $headers);
- $output = '<script>alert("Ваше сообщение получено, спасибо!");</script>';
- } else {
- $output = '<script>alert("Извините, письмо не отправлено. Размер всех файлов превышает 10 МБ.");</script>';
- }
- }
- ?>
- <!DOCTYPE HTML>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Контактная форма</title>
- <style>
- .feedback-form { /* вся форма */
- max-width: 550px;
- padding: 2%;
- border-radius: 3px;
- background: #f1f1f1;
- }
- .feedback-form label { /* наименование полей */
- float: left;
- display: block;
- clear: right;
- }
- .feedback-form .w100 { /* поля */
- float: right;
- max-width: 400px;
- width: 97%;
- margin-bottom: 1em;
- padding: 1.5%;
- }
- .feedback-form .border { /* граница полей */
- border-radius: 1px;
- border-width: 1px;
- border-style: solid;
- border-color: #C0C0C0 #D9D9D9 #D9D9D9;
- box-shadow: 0 1px 1px rgba(255,255,255,.5), 0 1px 1px rgba(0,0,0,.1) inset;
- }
- .feedback-form .border:focus {
- outline: none;
- border-color: #abd9f1 #bfe3f7 #bfe3f7;
- }
- .feedback-form .border:hover {
- border-color: #7eb4ea #97cdea #97cdea;
- }
- .feedback-form .border:focus::-moz-placeholder { /* убрать при фокусе первоначальный текст поля */
- color: transparent;
- }
- .feedback-form .border:focus::-webkit-input-placeholder {
- color: transparent;
- }
- .feedback-form .border:not(:focus):not(:hover):valid { /* правильно заполненные поля */
- opacity: .8;
- }
- .submitFF { /* кнопка "Отправить" */
- padding: 2%;
- border: none;
- border-radius: 3px;
- box-shadow: 0 0 0 1px rgba(0,0,0,.2) inset;
- background: #669acc;
- color: #fff;
- }
- .feedback-form br {
- height: 0;
- clear: both;
- }
- .submitFF:hover {
- background: #5c90c2;
- }
- .submitFF:focus {
- box-shadow: 0 1px 1px #fff, inset 0 1px 2px rgba(0,0,0,.8), inset 0 -1px 0 rgba(0,0,0,.05);
- }
- </style>
- <?php
- if (!empty($output)) {
- echo $output;
- }
- ?>
- <form enctype="multipart/form-data" method="post" class="feedback-form">
- <label for="nameFF">Имя:</label>
- <input type="text" name="nameFF" id="nameFF" required placeholder="например, Иван Иванович Иванов" x-autocompletetype="name" class="w100 border">
- <label for="contactFF">Email:</label>
- <input type="email" name="contactFF" id="contactFF" required placeholder="например, ivan@yandex.ru" x-autocompletetype="email" class="w100 border">
- <label for="fileFF">Прикрепить файл:</label>
- <input type="file" name="fileFF[]" multiple id="fileFF" class="w100">
- <label for="messageFF">Сообщение:</label>
- <textarea name="messageFF" id="messageFF" required rows="5" placeholder="Детали заявки…" class="w100 border"></textarea>
- <br>
- <input value="Отправить" type="submit" class="submitFF">
- </form>
- <form enctype="multipart/form-data" method="post" class="feedback-form">
- <label for="nameFF2">Имя:</label>
- <input type="text" name="nameFF2" id="nameFF2" required placeholder="например, Иван Иванович Иванов" x-autocompletetype="name" class="w100 border">
- <label for="contactFF2">Email:</label>
- <input type="email" name="contactFF2" id="contactFF2" required placeholder="например, ivan@yandex.ru" x-autocompletetype="email" class="w100 border">
- <label for="fileFF2">Прикрепить файл:</label>
- <input type="file" name="fileFF2[]" multiple id="fileFF2" class="w100">
- <label for="messageFF2">Сообщение:</label>
- <textarea name="messageFF2" id="messageFF2" required rows="5" placeholder="Детали заявки…" class="w100 border"></textarea>
- <br>
- <input value="Отправить" type="submit" class="submitFF">
- </form>
- <form enctype="multipart/form-data" method="post" class="feedback-form">
- <label for="nameFF3">Имя:</label>
- <input type="text" name="nameFF3" id="nameFF3" required placeholder="например, Иван Иванович Иванов" x-autocompletetype="name" class="w100 border">
- <label for="contactFF3">Email:</label>
- <input type="email" name="contactFF3" id="contactFF3" required placeholder="например, ivan@yandex.ru" x-autocompletetype="email" class="w100 border">
- <label for="fileFF3">Прикрепить файл:</label>
- <input type="file" name="fileFF3[]" multiple id="fileFF3" class="w100">
- <label for="messageFF3">Сообщение:</label>
- <textarea name="messageFF3" id="messageFF3" required rows="5" placeholder="Детали заявки…" class="w100 border"></textarea>
- <br>
- <input value="Отправить" type="submit" class="submitFF">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement