-
Notifications
You must be signed in to change notification settings - Fork 0
/
contactus.php
28 lines (23 loc) · 914 Bytes
/
contactus.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
<?php
$name = Trim(stripslashes($_POST['name']));
$email = Trim(stripslashes($_POST['email']));
$message = Trim(stripslashes($_POST['message']));
$to = '[email protected]';//your email address
$subject = 'the subject'; //subject email
$message = 'FROM: '.$name.' Email: '.$email.' Message: '.$message;
$headers = 'From: '.$email. "\r\n";
if (!empty($_POST['name']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) && !empty($_POST['message']) ) {
// detect & prevent header injections
$test = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $test, $val ) ) {
exit;
}
}
//send email
mail($to, $subject, $message, $headers);
echo "<p class='bg-success'>Thank you, your message was sent!</p>";
} else {
echo "<p class='bg-danger'>Upppss, you need to fill in all required fields or check invalid email format</p>";
}
?>