V
V
vetaliy_net2017-08-01 15:56:09
PHP
vetaliy_net, 2017-08-01 15:56:09

Why doesn't PHP submit form work for hosting?

The feedback form on the site does not work, I can not understand why, there is not a single error in the console.

When sending from an open server, everything arrives in the mail logs, and notifications about successful sending appear on the hosting, but nothing comes through.

<?php
if (isset($_POST['name'])){
$to = ""; 
$subject = '=?UTF8?B?'.base64_encode('Сообщение с сайта').'?=';
$sitename = "http://www.prav.online";

$name = trim($_POST["name"]);
$phone = trim($_POST["phone"]);
$message = trim($_POST["message"]);
$name = htmlspecialchars($name);
$phone = htmlspecialchars($phone);
$name = urldecode($name);
$phone = urldecode($phone);
$name = trim($name);
$phone = trim($phone);

$message = ' 
 
  
  
  
  
Имя: '.$name.'
Телефон: '.$phone.'
Текст: '.$message.'
  
'; 

$headers = "Content-type: text/html; charset=utf-8 \r\n"; 
$headers.= "From: ".$subject." <".$sitename.">\r\n"; 

mail($to, $subject, $message, $headers); 
}
?>


<form >
           <form action="/php.php" method="POST">
           <input type="text" name="name" placeholder="введите ваше имя">
           <input type="text" name="phone" placeholder="введите ваш телефон">
           <input type="hidden" name="source" value="">
           <input type="hidden" name="keyword" value="">
           <input type="hidden" class="ref" name="ref">
           <input type="hidden" name="myform" value="forma_verh" >
       
       <textarea name="message" placeholder="Введите вопрос или удобное для вас время для звонка"></textarea>
           <input type="button" value="Отправить">
         </form>


if(f==0){
        $.ajax({
          type: "POST",
          url: 'php.php',
          data: {name:name, phone:phone, source:source, keyword:keyword, ref:ref, message:message},
          success :function (data) {;
            ga('send', 'event', 'posle_proverki_formy', 'otpravit_zayavku', myform);

            $('.bg_popup').hide();
            $('.main_modal').hide();
            $('.modal').hide();

            $('.thankyou').css('top', $(window).scrollTop() + $(window).height() / 2 - $('.thankyou').height() / 2 ).show();
            $('.bg_popup').show();
            setTimeout(function(){
             $('.thankyou').hide();
             $('.bg_popup').hide();
           }, 8000); 
            $('input[type="text"]').val('');
            $('textarea').val('');
          },
          dataType : 'text'
        });
      }

$(document).ready(function() {

  $("form4").submit(function() {
    $.ajax({
      type: "POST",
      url: "/php.php",
      data: $(this).serialize()
    }).done(function() {
      $(this).find("input").val("");
      alert("Спасибо за заявку! Скоро мы с вами свяжемся.");
      $("form4").trigger("reset");
    });
    return false;
  });
  
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2017-08-01
@Stalker_RED

Most likely (95%, for example) that the hosting is not configured to send via mail().
Contact your hosting support or use PHPMailer .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question