echo json_encode(array('data' => $data));
break;
case 'feedback':
$name = filter($_POST['name']) ?? '';
$phone = filter($_POST['phone']) ?? '';
$email = filter($_POST['email']) ?? '';
$msg = filter($_POST['msg']) ?? '';
if (strlen($name) > 0 && strlen($phone))
{
$text = 'Имя: ' . $name . "\n";
$text .= 'Телефон: ' . $phone . "\n";
$text .= 'E-mail: ' . $email . "\n";
mail($mail, 'сайт - ' . $msg, $text, "From: no-reply@site.ru\r\nContent-type: text/plain; charset=utf-8\r\n");
echo json_encode(array('data' => 'ok'));
}
else
{
echo json_encode(array('data' => 'error'));
}
break;