Answer the question
In order to leave comments, you need to log in
Why is the form handler file not available in Wordpress?
Created the markup for the callback form.
<form class="form" action="<?php bloginfo('template_url') ?>/send.php" method="POST">
<input type="tel" name="tel" value="Phone">
<button class="button form__submit">Send</button>
</form>
<?php
require($_SERVER["DOCUMENT_ROOT"]."/wp-load.php");
$to = '[email protected]' // емайл получателя данных из формы
$tema = "Заявка с сайта"; // тема полученного емайла
$message = "Номер телефона: ".$_POST['tel']."";
$headers = 'MIME-Version: 1.0' . "\r\n"; // заголовок соответствует формату плюс символ перевода строки
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; // указывает на тип посылаемого контента
mail($to, $tema, $message, $headers,"-f [email protected]"); //отправляет получателю на емайл значения переменных\
?>
jQuery(function($){
$('.form').submit(function(e) {
e.preventDefault();
var $form = $(this);
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize()
}).done(function() {
console.log('success');
$form.trigger( 'reset' );
}).fail(function() {
console.log('fail');
});
});
});
POST https://domain.com/wp-content/themes/custom-theme/send.php 500 (Internal Server Error) | jquery.js?ver=1.12.4-wp:4
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