‘.$subject.’

500 ошибка

Пытаюсь отправить форму ajax и получаю 500 ошибку в консоли :POST http://site.ru/send.php 500 (Internal Server Error) прошу ответить может ли возникать данная ошибка из ошибок в самом обработчике php, или это что-то другое.

Добавлено через 16 минут
Прикрепляю обработчик. Знающие подскажите что в нем не так?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
 if(isset($_POST['client_phone'])&&$_POST['client_phone']!=""){ $to = 'dimitr5657@gmail.com'; $subject = 'сообщение с сайта'; $message = '      

Имя: '.$_POST['client_name'].'

Телефон: '.$_POST['client_phone'].'

Сообщение: '.$_POST['client_message'].'

'
; //Текст нащего сообщения можно использовать HTML теги $headers = "Content-type: text/html; charset=utf-8 \r\n"; //Кодировка письма $headers .= "mymail \r\n"; //Наименование и почта отправителя mail($to, $subject, $message, $headers); //Отправка письма с помощью функции mail } /** * upload.php * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ #!! IMPORTANT: #!! this file is just an example, it doesn't incorporate any security checks and #!! is not recommended to be used in production environment as it is. Be sure to #!! revise it and customize to your needs. // Make sure file is not cached (as it happens for example on iOS devices) header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); /* // Support CORS header("Access-Control-Allow-Origin: *"); // other CORS headers if any. if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') exit; // finish preflight CORS requests here > */ // 5 minutes execution time @set_time_limit(5 * 60); // Uncomment this one to fake upload time // usleep(5000); // Settings $targetDir = 'upload'; $cleanupTargetDir = true; // Remove old files $maxFileAge = 5 * 3600; // Temp file age in seconds // Create target dir if (!file_exists($targetDir)) { @mkdir($targetDir); } // Get a file name if (isset($_REQUEST["name"])) { $fileName = $_REQUEST["name"]; } elseif (!empty($_FILES)) { $fileName = $_FILES["file"]["name"]; } else { $fileName = uniqid("file_"); } $filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName; // Chunking might be enabled $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0; // Remove old temp files if ($cleanupTargetDir) if (!is_dir($targetDir) while (($file = readdir($dir)) !== false) { $tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file; // If temp file is current file proceed to the next if ($tmpfilePath == " .part") { continue; } // Remove temp file if it is older than the max age and is not the current file if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) time() - $maxFileAge)) { @unlink($tmpfilePath); } } closedir($dir); } // Open temp file if (!$out = @fopen(" .part", $chunks ? "ab" : "wb")) { die(', "id" : "id">'); } if (!empty($_FILES)) // Read binary input stream and append it to temp file if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) { die(', "id" : "id">'); } } else { if (!$in = @fopen("php://input", "rb")) { die(', "id" : "id">'); } } while ($buff = fread($in, 4096)) { fwrite($out, $buff); } @fclose($out); @fclose($in); // Check if file has been uploaded if (!$chunks || $chunk == $chunks - 1) { // Strip the temp .part suffix off rename(" .part", $filePath); if(isset($_POST['client_phone'])&&$_POST['client_phone']!=""){ $to = 'dimitr5657@gmail.com' $subject = 'сообщение с сайта'; $message = '

Имя: '.$_POST['client_name'].'

Телефон: '.$_POST['client_phone'].'

Сообщение: '.$_POST['client_message'].'

'
; //Текст нащего сообщения можно использовать HTML теги $headers = "Content-type: text/html; charset=utf-8 \r\n"; //Кодировка письма $headers .= "mymail \r\n"; //Наименование и почта отправителя mail($to, $subject, $message, $headers); //Отправка письма с помощью функции mail } } // Return Success JSON-RPC response die(''); ?>

Источник

Ошибка 500 при отправке данных формы при помощи phpMailer. Поможете?

В php разбираюсь очень плохо, поэтому прошу вас помочь с настройкой отправки формы через плагин phpMailer.

Вот сайт, на котором я пытаюсь настроить отпавку формы из 2 полей с именем и телефоном.

При отправке выскакивает ошибка 500, скрин 1 прилагаю:
6370f3bbeffe3210150173.jpeg
Скрин 2:
6370f3d105915298961777.jpeg
Я не эксперт, но походу какае-то ошибка в php файле, код прилагаю.

"use strict" document.addEventListener('DOMContentLoaded', function() < const form = document.getElementById('form'); form.addEventListener('submit', formSend); async function formSend(e) < e.preventDefault(); let error = formValidate(form); let formData = new FormData(form); if (error === 0) < form.classList.add('_sending'); let response = await fetch('sendmail.php', < method: 'POST', body: formData >); if (response.ok) < let result = await response.json(); alert(result.message); form.reset(); form.classList.remove('_sending'); >else < alert('Ошибка'); form.classList.remove('_sending'); >> else < alert('Заполните обязательные поля'); >> function formValidate(form) < let error = 0; let formReq = document.querySelectorAll('._req'); for (let i = 0; i < formReq.length; i++) < const input = formReq[i]; formRemoveError(input); if(input.classList.contains('_req') && input.value === '') < formAddError(input); error++; >> return error; > function formAddError(input) < input.parentElement.classList.add('_error'); input.classList.add('_error'); >function formRemoveError(input) < input.parentElement.classList.remove('_error'); input.classList.remove('_error'); >>);
CharSet = 'UTF-8'; $mail->setLanguage('ru', 'phpmailer/language/'); $mail->IsHTML(true); //От кого письмо $mail->setFrom('graffiti211@yandex.ru', 'Оле Арена'); //Кому отправить $mail->addAddress('graffiti211@yandex.ru'); //Тема письма $mail->Subject = 'Потенциальный клиент'; //Тело письма $body = '

Сэр, Вам письмо!

'; if (trim(!empty($_POST['name']))) < $body. = '

Имя: '.$_POST['name'].'

'; > if (trim(!empty($_POST['phone']))) < $body. = '

Телефон: '.$_POST['phone'].'

'; > $mail->Body = $body; //Отправляем if (!$mail->send()) < $message = 'Ошибка'; >else < $message = 'Данные отправлены!'; >$response = ['message' => $message]; header('Content-type: application/json'); echo json_encode($response); ?>

Буду благодарен за помощь!

Простой 1 комментарий

Источник

Ошибка 500 при отправке данных формы при помощи phpMailer. Поможете?

В php разбираюсь очень плохо, поэтому прошу вас помочь с настройкой отправки формы через плагин phpMailer.

Вот сайт, на котором я пытаюсь настроить отпавку формы из 2 полей с именем и телефоном.

При отправке выскакивает ошибка 500, скрин 1 прилагаю:
6370f3bbeffe3210150173.jpeg
Скрин 2:
6370f3d105915298961777.jpeg
Я не эксперт, но походу какае-то ошибка в php файле, код прилагаю.

"use strict" document.addEventListener('DOMContentLoaded', function() < const form = document.getElementById('form'); form.addEventListener('submit', formSend); async function formSend(e) < e.preventDefault(); let error = formValidate(form); let formData = new FormData(form); if (error === 0) < form.classList.add('_sending'); let response = await fetch('sendmail.php', < method: 'POST', body: formData >); if (response.ok) < let result = await response.json(); alert(result.message); form.reset(); form.classList.remove('_sending'); >else < alert('Ошибка'); form.classList.remove('_sending'); >> else < alert('Заполните обязательные поля'); >> function formValidate(form) < let error = 0; let formReq = document.querySelectorAll('._req'); for (let i = 0; i < formReq.length; i++) < const input = formReq[i]; formRemoveError(input); if(input.classList.contains('_req') && input.value === '') < formAddError(input); error++; >> return error; > function formAddError(input) < input.parentElement.classList.add('_error'); input.classList.add('_error'); >function formRemoveError(input) < input.parentElement.classList.remove('_error'); input.classList.remove('_error'); >>);
CharSet = 'UTF-8'; $mail->setLanguage('ru', 'phpmailer/language/'); $mail->IsHTML(true); //От кого письмо $mail->setFrom('graffiti211@yandex.ru', 'Оле Арена'); //Кому отправить $mail->addAddress('graffiti211@yandex.ru'); //Тема письма $mail->Subject = 'Потенциальный клиент'; //Тело письма $body = '

Сэр, Вам письмо!

'; if (trim(!empty($_POST['name']))) < $body. = '

Имя: '.$_POST['name'].'

'; > if (trim(!empty($_POST['phone']))) < $body. = '

Телефон: '.$_POST['phone'].'

'; > $mail->Body = $body; //Отправляем if (!$mail->send()) < $message = 'Ошибка'; >else < $message = 'Данные отправлены!'; >$response = ['message' => $message]; header('Content-type: application/json'); echo json_encode($response); ?>

Буду благодарен за помощь!

Простой 1 комментарий

Источник

Ошибка 500 при отправке данных формы

Всем привет) Делаю небольшой сайт на wordpresse. На нем имеется небольшая всплывающая форма, заполнив которую на сервер должно прийти письмо с данными формы. Реализовывал точно также на другом сайте — все работает, поставил на этом — сначала все отлично, потом вдруг перестало работать, при клике «оставить заявку» ничего не отправляется, а вылетает ошибка 500. Если кто сталкивался с такой проблемой, подскажите пожалуйста пути решения

1 2 3 4 5 6 7 8 9 10 11 12 13
div class="popup"> div class="popup_bg">/div> div class="form"> form id="send_frm" method="post" action="send.php">  --> h1 class="zak_call" >Заказать звонок/h1> p>Оставьте свой номер телефонаbr>и мы свяжемся с Вами/p> input type="text" placeholder="* Имя. " name="fio" style="" class="frm_el cons_frm" required=""> input type="text" id="tel" placeholder="* Телефон. " name="phone" style="" class="frm_el cons_frm" required="" > input type="text" name="usluga" style="display:none;"> input type="submit" value="Оставить заявку" name="submit" style="" class="btns frm_btn"> /form> /div> /div>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
script> document.getElementById('send_frm').onsubmit = function(){ if (this.fio.value!='' && this.phone.value!=''){ var http = new XMLHttpRequest(); http.open("POST", "template_url"); ?>/send/send.php", true); http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("&fio=" + this.fio.value + "&phone=" + this.phone.value + "&usluga=" + this.usluga.value ); http.onreadystatechange = function() { if (http.readyState == 4 && http.status == 200) { $(".popup").fadeOut(); $(".popup2").fadeIn(1000); document.getElementById("send_frm").fio.value=""; document.getElementById("send_frm").phone.value=""; $(".popup2").delay(3000).fadeOut(1000); } } http.onerror = function() { alert('Неудачно') // $(".popup3").fadeIn(1000); // $(".popup3").delay(3000).fadeOut(1000); } } else { alert('Заполните все обязательные поля!'); } return false; } script>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
 $to='4eqqqq@gmail.com' $fio = $_POST['fio']; $phone = $_POST['phone']; $usluga = $_POST['usluga']; $fio = htmlspecialchars($fio); $phone = htmlspecialchars($phone); $usluga = htmlspecialchars($usluga); $fio = urldecode($fio); $phone = urldecode($phone); $usluga = urldecode($usluga); $fio = trim($fio); $phone = trim($phone); $usluga = trim($usluga); $subject = 'Перезвоните мне!'; //Заголовок сообщения $message = $subject."\r\nИмя: ".$fio."\r\nТелефон: ".$phone."\r\nТип услуги: ".$usluga; $headers = "Content-type: text/html; charset=utf-8 \r\n"; //Кодировка письма $headers = "From: Правозащита в Кирове \r\n"; // echo "NHHHHS"; if (mail($to, $subject, $message, $headers)) { echo "сообщение успешно отправлено"; } else { echo "при отправке сообщения возникли ошибки"; } ?>

Самое смешное и обидное, что сначала то все работало, и не один день, а пару недель примерно. Может я случайно, где то стер какую-нибудь точку, не знаю. Во вложении скрин с ошибкой.

Источник

Читайте также:  Css text padding in table
Оцените статью