Skip to content

Instantly share code, notes, and snippets.

@vgrish
Last active March 12, 2016 07:49
Show Gist options
  • Save vgrish/39b83c043d655be2cb79 to your computer and use it in GitHub Desktop.
Save vgrish/39b83c043d655be2cb79 to your computer and use it in GitHub Desktop.
$('form').submit(function(e) {
e.preventDefault();
var name = $(this).find('.name').val();
$.post(
'mail.php', {
name: name,
},
function(d) {
}
);
});
=======
$name = substr(htmlspecialchars(trim($_POST['name'])), 0, 1000);
$to = 'mail';
$subject = 'subject'
$message = '
<html>
<head>
<title>'.$subject.'</title>
</head>
<body>
</body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'To: <'.$to.'>, '."\r\n";
$headers .= 'From: <mail.ru>' . "\r\n";
mail($to, $subject, $message, $headers);
echo 'Спасибо! Ваше письмо отправлено.';
header("Location: ".$_SERVER['HTTP_REFERER']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment