Answer the question
In order to leave comments, you need to log in
Why aren't letters coming?
Hello. Need help.
For your information:
There is a site written entirely in html , hosted by e-planet , php 5.2.17 , there is only one form on the site.
Question:
I put a feedback form, but it does not work. Why? An error in the code? Or the host is naughty?
The form:
<form class="mktoForm" id="feedback-form" method="POST" name="landingForm" onSubmit="createLead(); return false" action="http://www.сайт.ru">
<div class="form-row">
<input type="hidden" name="formData" value="Форма обратной связи с сайта www.сайт.ru">
<div class="form-group col-lg-6">
<label for="recipient_name" class="col-form-label">Представьтесь, пожалуйста</label>
<input type="text" class="form-control" name="name" id="recipient_name" placeholder="Иванов Иван Игоревич" required="required" autocomplete="on">
</div>
<div class="form-group col-lg-6">
<label for="recipient-phone" class="col-form-label">Телефон</label>
<input type="text" class="form-control" name="phone" id="recipient_phone" placeholder="+7" required="required" autocomplete="on">
</div>
<div class="form-group col-md-12">
<label for="recipient_mail" class="col-form-label">Email</label>
<input type="text" class="form-control" name="mail" id="recipient_mail" placeholder="[email protected]" required="required" autocomplete="on">
</div>
<div class="form-group col-md-12">
<label for="recipient_message" class="col-form-label">Текст обращения</label>
<textarea class="form-control message" name="message" id="recipient_message" placeholder="Введите сообщение" required="required"></textarea>
</div>
</div>
<div class="text-center">
<button type="submit" class="btn btn-danger uppercase bold mx-2 my-1">Отправить сообщение</button> <button type="button" class="btn btn-danger uppercase bold mx-2 my-1" onclick="form.reset()">Очистить</button>
</div>
</form>
document.getElementById('feedback-form').addEventListener('submit', function(evt) {
var http = new XMLHttpRequest(),
f = this;
evt.preventDefault();
http.open("POST", "feedback.php", true);
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
http.send("name=" + f.name.value + "&mail=" + f.mail.value + "&phone=" + f.phone.value + "&message=" + f.message.value);
http.onreadystatechange = function() {
if (http.readyState == 4 && http.status == 200) {
document.getElementById("form_contact").innerHTML = "<div id='okform' class='text-center'><p style='font-size:1rem'>Спасибо за отправку вашего сообщения! <br>Наши специалисты свяжутся с вами в течение часа.</p><div class='ksadake'><svg viewbox='0 0 48 48' xmlns='http://www.w3.org/2000/svg'><path d='M 18 32.34 l -8.34 -8.34 -2.83 2.83 11.17 11.17 24 -24 -2.83 -2.83 z' stroke='#3da35a' fill='transparent'/></svg></div></div>";
f.message.removeAttribute('value');
f.message.value = '';
}
}
http.onerror = function() {
document.getElementById("form_contact").innerHTML = "<div id='errform' class='text-center'><p style='font-size:1rem'>Ошибка. Сообщение не отправлено! Проверьте правильность введенных данных</p><div class='ksadake'><svg id='psfmje' width='12' height='12' viewBox='0 0 12 12' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><defs><linearGradient x1='0%' y1='0%' x2='100%' y2='100%' id='linearGradient-1'><stop stop-color='#DD5497' offset='0%'></stop><stop stop-color='#F9BDAA' offset='100%'></stop></linearGradient></defs><g stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'><g transform='translate(-1022.000000, -5316.000000)' fill='url(#linearGradient-1)' id='Pricing-Guide'><g transform='translate(150.000000, 4786.000000)'><path d='M880.058875,536 L884,539.941125 L881.941125,542 L878,538.058875 L874.058875,542 L872,539.941125 L875.941125,536 L872,532.058875 L874.058875,530 L878,533.941125 L881.941125,530 L884,532.058875 L880.058875,536 Z' id='Combined-Shape-Copy-6'></path></g></g></g></svg></div></div>";
}
}, false);
<?
if (array_key_exists('message', $_POST)) {
$to = 'кому@mail.ru';
$subject = 'Заявка с сайта '.$_SERVER['HTTP_REFERER'];
$subject = "=?utf-8?b?". base64_encode($subject) ."?=";
$message = "Имя: ".$_POST['name']."\nEmail: ".$_POST['mail']."\nТелефон: ".$_POST['phone']."\nIP: ".$_SERVER['REMOTE_ADDR']."\nСообщение: ".$_POST['message'];
$headers = 'Content-type: text/plain; charset="utf-8"';
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Date: ". date('D, d M Y h:i:s O') ."\r\n";
mail($to, $subject, $message, $headers);
echo $_POST['name'];
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question