-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.php
216 lines (186 loc) · 6.27 KB
/
contact.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
include "page_template.html"
?>
<div id="temp-content" style="display: none;">
<h3>Contact</h3>
<hr>
<br>
<p>
MAIL: eemanuele [punto] bellini [chiocciola] gmail [punto] com
</p>
<br>
<p>
PHONE: +39 393 55 680 22
</p>
<br>
<p>
LINKEDIN: https://it.linkedin.com/in/emabellini
</p>
<br><br><hr><br>
<p>
...or drop me a message here:
</p><br>
<form id="contact-form" action="contact.php" method="POST" >
<div class="row">
<label for="name">Name:</label><br>
<input id="name" class="input" name="name"
placeholder="your name" type="text"
value="" /><br />
</div>
<div class="row">
<label for="email">Email:</label><br>
<input id="email" class="input" name="email"
placeholder="your email"
type="email" value=""/><br />
</div>
<div class="row">
<label for="message">Message:</label><br />
<textarea id="message" class="input" name="message"
placeholder="your message"></textarea><br />
</div>
<div class="row">
<label for="human">
*Which is the first prime number? (Anti-spam)
</label><br />
<input name="human" class="input" name="human"
placeholder="your answer" value=""/>
</div>
<br>
<input id="submit-button" name="submit" type="submit" value="SEND EMAIL"
onmouseover="submitOverFunction()"
onmouseleave="submitLeaveFunction()"/>
</form>
<?php
$name = test_input($_POST['name']);
//$name = $_POST['name'];
$email = test_input($_POST['email']);
//$email = $_POST['email'];
$message = test_input($_POST['message']);
//$message = $_POST['message'];
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
$from = 'From: EmaProWebSite';
$to = '[email protected]';
$subject = 'Hello';
$human = test_input($_POST['human']);
//$human = $_POST['human'];
function test_input($data) {
$data = trim($data); // Strip unnecessary characters (extra space, tab, newline) from the user input data
$data = stripslashes($data); // Remove backslashes (\) from the user input data
$data = htmlspecialchars($data);
return $data;
}
//echo '<p>POST_submit:</p>' . $_POST['submit'] ;
if ($_POST['submit'] && $human == '2') {
//echo '<p>MAIL RESULT:</p>' . mail ($to, $subject, $body, $from) ;
// NOTE: for the mail function to work,
// a mail server must be installed on the web server
if (mail ($to, $subject, $body, $from)) {
echo '<br><p style="color: blue;">Your message has been sent! Thank you!</p>';
$_POST['name'] = "" ;
$_POST['email'] = "" ;
$_POST['message'] = "" ;
$_POST['human'] = "" ;
} else {
echo '<br><p style="color: red;">Something went wrong, go back and try again!</p>';
}
} else if ($_POST['submit'] && $human != '2') {
echo '<br><p style="color: red;">You answered the anti-spam question incorrectly!</p>';
}
?>
<!--
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form id="contact-form" action="contact.php" method="POST" enctype="multipart/form-data">
<div class="row">
<label for="name">Name:</label><br>
<input id="name" class="input" name="name" placeholder="your name" type="text" value="" /><br />
</div>
<div class="row">
<label for="email">Email:</label><br>
<input id="email" class="input" name="email" placeholder="your_email@your_domain.something" type="email" value=""/><br />
</div>
<div class="row">
<label for="message">Message:</label><br />
<textarea id="message" class="input" name="" placeholder="your message" ></textarea><br />
</div>
<br>
<input id="submit-button" type="submit" value="SEND EMAIL"
onmouseover="submitOverFunction()"
onmouseleave="submitLeaveFunction()"/>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("[email protected]", $subject, $message, $from);
echo "Email sent!";
}
}
?>
-->
</div>
<script>
var chapter = 'contact' ;
var x = document.getElementById('temp-content') ;
document.getElementById('main').innerHTML = x.innerHTML ;
</script>
<script>
// STYLE
var x ;
x = document.getElementById('contact-form') ;
x.textAlign = 'center' ;
x.style.width = document.getElementById('temp-content').width ;
//x.style.padding = '20px' ;
//x.style.width = '100%' ;
var textBgColor = '#707070' ;
var textColor = '#F0F0F0' ;
x = document.getElementsByClassName('input') ;
var i ;
for (i = 0; i < x.length; i++) {
x[i].style.border = '3px solid #cccccc' ;
x[i].style.width = '100%' ;
x[i].style.backgroundColor = textBgColor ;
x[i].style.color = textColor ;
x[i].style.padding = '3px' ;
//x[i].style.margin = '0px' ;
// to make text area fit with the borders (otherwise the exceed the 100%)
x[i].style.boxSizing = 'border-box' ;
}
x = document.getElementById('message') ;
x.style.height = '200px' ;
x = document.getElementById('submit-button') ;
x.style.border = '3px solid #cccccc' ;
x.style.width = '100%' ;
x.style.backgroundColor = textBgColor ;
x.style.fontFamily = '"Open Sans", sans-serif' ;
x.style.fontWeight = '600' ;
x.style.fontVariant = 'small-caps' ;
x.style.color = textColor ;
function submitOverFunction() {
var y ;
y = document.getElementById("submit-button") ;
y.style.backgroundColor = '#CCCCCC' ;
y.style.color = '#000000' ;
}
function submitLeaveFunction() {
var y ;
y = document.getElementById("submit-button") ;
y.style.backgroundColor = textBgColor ;
y.style.color = textColor ;
}
</script>
<!--
-->