-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.php
96 lines (45 loc) · 1.48 KB
/
mail.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?
// ----------------------------конфигурация-------------------------- //
$adminemail="[email protected]"; // e-mail админа
$date=date("d.m.y"); // число.месяц.год
$time=date("H:i"); // часы:минуты:секунды
$backurl="https://kkadet.github.io"; // На какую страничку переходит после отправки письма
//---------------------------------------------------------------------- //
// Принимаем данные с формы
$name=$_POST['name'];
$email=$_POST['email'];
$message=$_POST['message'];
// Проверяем валидность e-mail
if (!preg_match("|^([a-z0-9_\.\-]{1,20})@([a-z0-9\.\-]{1,20})\.([a-z]{2,4})|is",
strtolower($email)))
{
echo
"<center>Вернитесь <a
href='javascript:history.back(1)'><B>назад</B></a>. Вы
указали неверные данные!";
}
else
{
$msg="
<p>Имя: $name</p>
<p>E-mail: $email</p>
<p>Сообщение: $msg</p>
";
// Отправляем письмо админу
mail("$adminemail", "$date $time Сообщение
от $name", "$msg");
// Сохраняем в базу данных
$f = fopen("message.txt", "a+");
fwrite($f," \n $date $time Сообщение от $name");
fwrite($f,"\n $msg ");
fwrite($f,"\n ---------------");
fclose($f);
// Выводим сообщение пользователю
print "<script language='Javascript'><!--
function reload() {location = \"$backurl\"}; setTimeout('reload()', 6000);
//--></script>
$msg
<p>Сообщение отправлено! Подождите, сейчас вы будете перенаправлены на главную страницу...</p>";
exit;
}
?>