-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend-form.php
More file actions
executable file
·87 lines (83 loc) · 2.63 KB
/
send-form.php
File metadata and controls
executable file
·87 lines (83 loc) · 2.63 KB
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
<?
header('Content-Type: text/html; charset=utf-8');
if ($_POST['do'] == 'send'){
$data = $_POST;
if ($data['surname'] == '' || $data['surname'] == 'Your Name'){
$body = '<span style="color:#fff">Your Name field is required</span>';
?>
showError('if1');
<?
} else {
if ($data['email'] == '' || $data['email'] == 'Email'){
$body = '<span style="color:#fff">Email field is required</span>';
?>
showError('if1');
<?
}
else {
if (!preg_match('/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)*(\.[a-z]{2,4})$/i', $data['email'])){
$body = '<span style="color:#fff">Email is not a valid</span>';
?>
showError('if1');
<?
} else {
$to = '[email protected]';
$toName = 'Test';
$subject = 'Contact form';
$message =
<html>
<head>
<title>Contact form</title>
</head>
<body>
<h1>Contact form</h1>
<table cellpadding="5" cellspacing="0">
<tr>
<th align="right">Your Name:</th>
<td>'.iconv('utf-8', 'windows-1251', $data['surname']).'</td>
</tr>
<tr>
<th align="right">Email:</th>
<td>'.iconv('utf-8', 'windows-1251', $data['email']).'</td>
</tr>
<tr>
<th align="right">Subject:</th>
<td>'.iconv('utf-8', 'windows-1251', $data['website']).'</td>
</tr>
<tr>
<th colspan="2">Message:</th>
</tr>
<tr>
<td colspan="2">'.iconv('utf-8', 'windows-1251', $data['message']).'</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
// Additional headers
//$headers .= 'To: '.$toName.' <'.$to.'>' . "\r\n";
$headers .= 'From: '.$data['name'].' <'.$data['email'].'>' . "\r\n";
//$headers .= 'Cc: [email protected]' . "\r\n";
//$headers .= 'Bcc: [email protected]' . "\r\n";
// Mail it
if (mail($to, $subject, $message, $headers)){
$body = '<span style="color:#fff">Contact form submitted!</span>';
?>
<!--$("#f1").fadeOut(800);-->
showDone('ifl');
<?
} else {
$body = '<span style="color:#2CAFE4">Contact form error</span>';
?>
showError('if1');
<?
}
}
}
}
}
?>
$("#events").html('<?=$body?>').fadeIn(800);