Y
Y
yarluk072018-02-02 17:03:08
PHP
yarluk07, 2018-02-02 17:03:08

The feedback form is not working, what's wrong?

the form does not work, it says sent, but the letter itself does not arrive:
HTML

<div class="form">
              <form> 
                <div class="form-heading">
                    <h6>Получите доступ </h6>
                    <p>к оптовым ценам <span>+ скидку до 25 000 грн</span>. на заказ</p>
                </div>
                <div class="form-content">
                    <div class="form-group form-group1">
                        <label>Имя</label>
                        <input type="text" name="name" class="name required">
                    </div>
                    <div class="form-group form-group2">
                        <label>Телефон</label>
                        <input type="text" name="phone" class="phone required">
                    </div>
                    <div class="form-group form-group3">
                        <label>E-mail</label>
                        <input type="text" name="email" class="email required">
                    </div>
                    <a href="#" class="submit ORDER1">Получить доступ</a>
                    <p>Мы гарантируем  конфиденциальность ваших  данных</p>
                </div>
              </form>
        </div></blockquote>

PHP  <blockquote><?
if((isset($_POST['name'])&&$_POST['name']!="")&&(isset($_POST['phone'])&&$_POST['phone']!="")&&(isset($_POST['email'])&&$_POST['email']!="")){ //Проверка отправилось ли наше поля name и не пустые ли они
        $to = '[email protected]'; //Почта получателя, через запятую можно указать сколько угодно адресов
        $subject = 'метал интерос'; //Загаловок сообщения
        $message = '
                <html>
                    <head>
                        <title>'.$subject.'</title>
                    </head>
                    <body>
                        <p>Имя: '.$_POST['name'].'</p>
                        <p>Телефон: '.$_POST['phone'].'</p>
                        <p>E-mail: '.$_POST['email'].'</p>

                    </body>
                </html>'; //Текст нащего сообщения можно использовать HTML теги
        $headers  = "Content-type: text/html; charset=utf-8 \r\n"; //Кодировка письма
        $headers .= "From: Заявка <[email protected]>\r\n"; //Наименование и почта отправителя
        mail($to, $subject, $message, $headers); //Отправка письма с помощью функции mail
}
        ?></blockquote>

JS  <blockquote>$(document).ready(function() {
        var a;
        $(".catalog .item .btn").on("click", function() {
            a = $(this).parent().find(".productName").text()
        }), $(".submit").on("click", function(b) {
            b.preventDefault();
            var c = !1;
            if ($(this).hasClass("ORDER1")) var d = "ORDER1";
            if ($(this).hasClass("ORDER2")) var d = "ORDER2";
            if ($(this).hasClass("ORDER3")) var d = "ORDER3";
            if ($(this).hasClass("ORDER4")) var d = "ORDER4";
            if ($(this).hasClass("ORDER5")) var d = "ORDER5";
            if ($(this).parent().find(".required").each(function() {
                    if ($(this).hasClass("name")) {
                        if (0 == $(this).val().length) return c = !0, $(this).parent().addClass("err").effect("bounce", 400), $(this).popover({
                            placement: "top",
                            trigger: "focus ",
                            content: "Введите имя"
                        }), $(this).popover("show").trigger("focus"), !1;
                        $(this).parent().removeClass("err"), $(this).popover("destroy"), c = !1
                    } else if ($(this).hasClass("phone")) {
                        if (!validate($(this).val(), "phone")) return c = !0, $(this).parent().addClass("err").effect("bounce", 400), $(this).popover({
                            placement: "top",
                            trigger: "focus ",
                            content: "Введите телефон"
                        }), $(this).popover("show").trigger("focus"), !1;
                        $(this).parent().removeClass("err"), $(this).popover("destroy"), c = !1
                    } else if ($(this).hasClass("email")) {
                        if (!validate($(this).val(), "email")) return c = !0, $(this).parent().addClass("err").effect("bounce", 400), $(this).popover({
                            placement: "top",
                            trigger: "focus ",
                            content: "Введите e-mail"
                        }), $(this).popover("show").trigger("focus"), !1;
                        $(this).parent().removeClass("err"), $(this).popover("destroy"), c = !1
                    }
                }), c === !1) {
                var e = {};
                0 != $(this).parent().find(".name").val() && (e.name = $(this).parent().find(".name").val()), 0 != $(this).parent().find(".phone").val() && (e.phone = $(this).parent().find(".phone").val()), 0 != $(this).parent().find(".email").val() && (e.email = $(this).parent().find(".email").val()), 0 != a && (e.productName = a), $(":input", ".form").val(""), a = "", $.ajax({
                    url: "php/mail.php",
                    type: "POST",
                    data: "jsonData=" + $.toJSON(e),
                    success: function() {
                        return $.fancybox.close(), $.fancybox({
                            href: "#thank-you",
                            padding: 0
                        }), "ORDER1" == d ? (yaCounter47505106.reachGoal("ORDER1"), !0) : "ORDER2" == d ? (yaCounter47505106.reachGoal("ORDER2"), !0) : "ORDER3" == d ? (yaCounter47505106.reachGoal("ORDER3"), !0) : "ORDER4" == d ? (yaCounter47505106.reachGoal("ORDER4"), !0) : "ORDER5" == d ? (yaCounter47505106.reachGoal("ORDER5"), !0) : "ORDER6" == d ? (yaCounter47505106.reachGoal("ORDER6"), !0) : void 0
                    }
                })
            }
        })
    });

please help me figure it out

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-02-02
@AK-VoronM

Terrible!
You have a parameter with the name jsonData in your post, respectively, and you need to receive this parameter . The $array array contains the form data. If you passed them correctly from js. If you definitely want to work directly with $_POST, then you need to pass a serialized form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question