Dokuro Тян Так? Почему-то не работает.
<?php
if (isset($_POST['action']))
{
subject = $_REQUEST['subject'] . 'Новое письмо';
$to = 'example@mail.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: info@mail.com'. "\r\n"
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$message .= '<b>Имя:</b> ' . $_REQUEST['name'] . "<br><br>";
$message .= '<b>Почта:</b> ' . $_REQUEST['mail'];
if (@mail($to, $subject, $message, $headers))
{
echo 'success';
}
else
{
echo 'fail';
}
}
?>
<script type="text/javascript">
$.post("index.php?action", $("#form").serialize(), function(result){
if(result == 'success'){
$('#form').fadeOut(500);
}else{
$('#form').html("<span class='red'>Fail!</span>");
}
});
</script>
<form name="form" id="form" method="post" action='email.php'>
<input type="text" name="name" id="name">
<input type="text" name="mail" id="mail">
<button type="button" id="button">Отправить</button>
</form>