-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontact.inc.php
56 lines (50 loc) · 1.36 KB
/
contact.inc.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
<?php
require_once "./functions/db.php";
require_once "./functions/functions.php";
require_once "./functions/validation.php";
// echo "<pre>";
// print_r($_POST);
// Array
// (
// [name] => ankit bhusal
// [email] => [email protected]
// [subject] => random
// [message] => sjdasdjaksdj askd asdj alkda sdlk asd
// )
$name = strip_tags(request('name'));
$email = strip_tags(request('email'));
$subject = strip_tags(request('subject'));
$message = strip_tags(request('message'));
if (empty($name) || empty($email) || empty($subject) || empty($message)) {
setError("Please fill all the fields!!");
header("Location: ./contact.php");
die;
}
if (!validateName($name)) {
setError('Please enter valid name!!');
header("Location: ./contact.php");
die;
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
setError("Please enter valid email!!");
header("Location: ./contact.php");
die;
}
if (!validateName($subject)) {
setError("Please enter valid subject!!");
header("Location: ./contact.php");
die;
}
$to = '[email protected]';
// Additional headers
$headers = "From: $email";
// mail input form to admin
if (mail($to, $subject, $message, $headers)) {
setSuccess("Email sent!!");
header("Location: ./contact.php");
die;
} else {
setError('Email sent failed!');
header("Location: ./contact.php");
die;
}