Письмо приходит пустым. JS:
registerCoupon() {
axios.post('final/php/registerCoupon.php', new FormData(this.$refs.couponForm))
.then((res) => {
if ( res != null ) {
this.couponPrinter = true;
this.tel = '';
this.surname = '';
console.log(res);
console.log(this.tel);
console.log(this.surname);
} else {
this.couponPrinter = false;
alert('Возникла ошибка! Попробуйте позже')
}
})
.catch((err) => {
console.error(err)
})
}
PHP:
<?php
$recepient = "почта";
$sitename = "mh36.ru";
$name = $_POST["name"];
$tel = $_POST["tel"];
$date = trim($_POST['none']);
$message = "Имя Фамилия: $name \nНомер телефона: $tel \nДата купона: $date";
$pagetitle = "Бронирование купона";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient");
?>
HTML:
<form @submit.prevent="registerCoupon()" method="post" ref="couponForm">
<input type="text" name="name" pattern='[а-яА-ЯёЁ]{4,64} [а-яА-ЯёЁ]{4,64}' v-model="surname" placeholder="Введите ваше имя и фамилию" required :title='titleGen'>
<input type="tel" name="tel" v-model="tel" v-mask="'+7 (###) ###-##-##'" placeholder="Введите ваш номер телефона" required title="Используйте только цифры">
<button type="submit">Отправить</button>
<transition name="fade">
<div class="p-coupon__activate" v-if="couponPrinter">
<p>Купон активирован! Вам осталось его распечатать и предъявить администратору. В один день вы можете активировать только один купон!</p>
<button @click="printCoupon(index)">Распечатать</button>
</div>
</transition>
</form>
Notice: Undefined variable: nameCoupon
. Так с двумя переменными.