-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontacts.php
69 lines (57 loc) · 1.85 KB
/
contacts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="ru">
<head>
<?php
$website_title = "Контакты";
require "blocks/head.php"
?>
</head>
<body>
<?php require "blocks/header.php"?>
<main>
<h1>Контакты</h1>
<form>
<label for="username">Ваше имя</label>
<input type="text" name="username" id="username">
<label for="email">Email</label>
<input type="email" name="email" id="email">
<label for="mess">Сообщение</label>
<textarea name="mess" id="mess"></textarea>
<div class="error-mess" id="error-block"></div>
<button type="button" id="mess_send">Отправить</button>
</form>
</main>
<?php require "blocks/aside.php"?>
<?php require "blocks/footer.php"?>
<script>
$('#mess_send').click(function() {
let name = $('#username').val();
let email = $('#email').val();
let mess = $('#mess').val();
$.ajax({
url: 'ajax/mail.php',
type: 'POST',
cache: false,
data: {
'name': title,
'email': email,
'mess': mess
},
dataType: 'html',
success: function(data) {
if(data === "Done") {
$("#mess_send").text("Все готово");
$("#error-block").hide();
$('#username').val("");
$('#email').val("");
$('#mess').val("");
} else {
$("#error-block").show();
$("#error-block").text(data);
}
}
});
});
</script>
</body>
</html>