The problem: Javascript function( which was premade by template) cleans the form data sent to me by php
The php code:
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'GJ '
);
$name = @trim(stripslashes($_POST['name']));
$phone = @trim(stripslashes($_POST['phone']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$email_to = 'email@email.com';//replace with your email
$body = 'Name: ' . $name . "
" . 'Телефон: ' . $phone . "
" . 'Subject: ' . $subject . "
" . 'Message: ' . $message;
$success = @mail($email_to, $subject, $body);
echo json_encode($status);
die;
The javascript function code:
var form = $('.contact-form');
form.submit(function () {'use strict',
$this = $(this);
$.post($(this).attr('action'), function(data) {
$this.prev().text(data.message).fadeIn().delay(3000).fadeOut();
},'json');
return false;
});
When there's no js code php returns white screen with a line but the @mail sends normal message, but when there is this code fade in and out works good, but the data arrives empty. The message in message and name is cyrylic if that is important.
Please help me fix it(i.e. i need both data arriving and success fade-in appearing or at least data arriving with no .php white screen) or just explain what the js code does i don't get it. Thanks