-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.php
46 lines (34 loc) · 1.13 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
<?php
/*
The Send Mail php Script for Contact Form
Server-side data validation is also added for good data validation.
*/
$data['error'] = false;
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$website = $_POST['website'];
$message = $_POST['message'];
if( empty($name) ){
$data['error'] = 'Please enter your name.';
}else if(filter_var($email, FILTER_VALIDATE_EMAIL) == false){
$data['error'] = 'Please enter a valid email address.';
}else if( empty($message) ){
$data['error'] = 'The message field is required!';
}else if( empty($phone) ){
$data['error'] = 'Please enter your phone number.';
}else if ( empty($website) ){
$data['error'] = 'Please enter your website.';
}else{
$formcontent="From: $name\nPhone: $phone\nWebsite: $website\nEmail: $email\nMessage: $message";
//Place your Email Here
$recipient = "[email protected]";
$mailheader = "From: $email \r\n";
if( mail($recipient, $name, $formcontent, $mailheader) == false ){
$data['error'] = 'Sorry, an error occured!';
}else{
$data['error'] = false;
}
}
echo json_encode($data);
?>