Is the most common form of written hands.
Handler
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST['name'])) {$name = $_POST['name'];}
if (isset($_POST['phone'])) {$phone = $_POST['phone'];}
if (isset($_POST['text'])) {$text = $_POST['text'];}
if (isset($_POST['formData'])) {$formData = $_POST['formData'];}
$to = "artyomunder@gmail.com"; /*Specify the address of the ha which must be a letter*/
$sendfrom = "support@sitename.ru"; /*Specify the address from which will come the letter is not real, it is necessary for the formation of the email header*/
$headers = "From:" . strip_tags($sendfrom) . "\r\n";
$headers .= "Reply-To: ". strip_tags($sendfrom) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=utf-8 \r\n";
$subject = "$formData";
$message = "$formData<br/-->
<b>the name of the sent:</b> $name<br>
<b>Phone:</b> $phone<br>
<b>Message:</b>$text
";
$send = mail ($to, $subject, $message, $headers);
if ($send == 'true')
{
echo '<center>Your message has been sent, thank you! Our Manager will contact You shortly.</center>';
}
else
{
echo '<center>
<b>Error. The message was not sent!</b>
</center>';
}
}?>
Js
$(function(){
$('.form-footer').on('submit', function(e){
e.preventDefault();
var $that = $(this),
formData = new FormData($that.get(0));
$.ajax({
url: $that.attr('action'),
type: $that.attr('method'),
contentType: false,
processData: false,
data: formData,
dataType: 'html',
success: function(form){
if(form){
$that.replaceWith(form);
}
}
});
});
});
Form
<form class="form-footer" action method="post">
<div class="row">
<div class="col-md-6 npl"><input type="text" name="name" class="input-medium placeh-white" placeholder="Your name"></div>
<div class="col-md-6 npall"><input type="text" name="phone" class="input-medium placeh-white" placeholder="Your phone"></div>
<div class="col-md-12 npall">
<textarea placeholder="message" name="text" class="placeh-white"></textarea>
</div>
<button class="btn-medium" type="submit" name="submit">Send</button>
</div>
</form>
All sends, but after sending loads the whole page in the place where they were form.
The website on Bitrix, what the fuck is this?
Try the form's action to register the full path to the handler. - rhianna_Fee commented on June 10th 19 at 15:44