Answer the question
In order to leave comments, you need to log in
The form does not send data to the mail, how to fix it?
There is a form that should send the data entered by the user to the mail, but for some reason it does not, does anyone know how to fix it?
<form name="sentMessage" action="mail.php" method="POST" id="contactForm" novalidate="">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" placeholder="Ваше имя *" id="name" name="user_name" required="" data-validation-required-message="Укажите пожалуйста ваше имя.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input type="number" class="form-control" placeholder="Ваш телефон *" id="email" name="user_phone" required="" data-validation-required-message="Укажите пожалуйста ваш номер телефона.">
<p class="help-block text-danger"></p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<textarea class="form-control" placeholder="Ваше сообщение" id="message" name="user_message" required="" data-validation-required-message="Напишите пожалуйста ваше сообщение"></textarea>
<p class="help-block text-danger"></p>
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="row">
<div class="col-lg-12 text-center">
<button type="submit" class="btn">Готово</button>
</div>
</div>
</form>
<?php
require_once('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->CharSet = 'utf-8';
$name = $_POST['user_name'];
$phone = $_POST['user_phone'];
$message = $_POST['user_message'];
$mail->isSMTP();
$mail->Host = 'smtp.mail.ru'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'password';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom('[email protected]');
$mail->addAddress('[email protected]');
$mail->isHTML(true);
$mail->Subject = 'Message';
$mail->Body = '' .$name . ' number:' .$phone. '<br>Message:: ' .$message;
$mail->AltBody = '';
if(!$mail->send()) {
echo 'Error';
} else {
header('location: allisworking.html');
}
?>
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