-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.php
42 lines (36 loc) · 1002 Bytes
/
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
<?php
// get posted data into local variables
$EmailTo = "[email protected]";
$Subject = "Message from website";
$Name = Trim(stripslashes($_POST['contact-name']));
$EmailFrom = Trim(stripslashes($_POST['contact-email']));
$Message = Trim(stripslashes($_POST['contact-message']));
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<h2>There was an error. Please try to send the messake again. </h2>";
exit;
}
// prepare email body text
$Body = "You've got this email from your website:";
$Body .= "\r\n";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\r\n";
$Body .= "Email: ";
$Body .= $EmailFrom;
$Body .= "\r\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\r\n";
// send email
$success = mail( $EmailTo, $Subject, $Body );
//redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">";
}
?>