-
Notifications
You must be signed in to change notification settings - Fork 0
/
contacto.php
58 lines (47 loc) · 1.8 KB
/
contacto.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
<?php
if($_POST) {
$visitor_name = "";
$visitor_email = "";
$email_title = "";
$concerned_department = "";
$visitor_message = "";
if(isset($_POST['visitor_name'])) {
$visitor_name = filter_var($_POST['visitor_name'], FILTER_SANITIZE_STRING);
}
if(isset($_POST['visitor_email'])) {
$visitor_email = str_replace(array("\r", "\n", "%0a", "%0d"), '', $_POST['visitor_email']);
$visitor_email = filter_var($visitor_email, FILTER_VALIDATE_EMAIL);
}
if(isset($_POST['email_title'])) {
$email_title = filter_var($_POST['email_title'], FILTER_SANITIZE_STRING);
}
if(isset($_POST['concerned_department'])) {
$concerned_department = filter_var($_POST['concerned_department'], FILTER_SANITIZE_STRING);
}
if(isset($_POST['visitor_message'])) {
$visitor_message = htmlspecialchars($_POST['visitor_message']);
}
if($concerned_department == "ventas") {
$recipient = "[email protected]";
}
else if($concerned_department == "capacitacion") {
$recipient = "[email protected]";
}
else if($concerned_department == "sugerencias") {
$recipient = "[email protected]";
}
else {
$recipient = "[email protected]";
}
$headers = 'MIME-Version: 1.0' . "\r\n"
.'Content-type: text/html; charset=utf-8' . "\r\n"
.'From: ' . $visitor_email . "\r\n";
if(mail($recipient, $email_title, $visitor_message, $headers)) {
echo "<p>Gracias por contactarnos, $visitor_name. Te responderemos lo más pronto posible.</p>";
} else {
echo '<p>Lo sentimos hay un problema con el email.</p>';
}
} else {
echo '<p>Ocurrió un error</p>';
}
?>