-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcontato.php
More file actions
90 lines (81 loc) · 2.94 KB
/
contato.php
File metadata and controls
90 lines (81 loc) · 2.94 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
$sucesso = false;
if (isset($_POST['nome'])) {
$aviso = '';
$nome = $_POST['nome'];
$email = $_POST['email'];
$area = $_POST['area'];
$mensagem = $_POST['mensagem'];
if(empty($nome)){
$aviso .= 'Favor preencher o nome<br />';
}
if(empty($email)){
$aviso .= 'Favor preencher o email<br />';
}
if(empty($area)){
$aviso .= 'Favor preencher a area<br />';
}else{
if($area == 'vendas'){
$email_to = 'vendas@iparos.com.br';
}elseif($area == 'suporte'){
$email_to = 'suporte@iparos.com.br';
}else{
$aviso .= 'Área seleciona é inválida<br />';
}
}
if(empty($mensagem)){
$aviso .= 'Favor preencher a mensagem<br />';
}
if(empty($aviso) && isset($email_to)){
$body = '
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
Email enviado através do site<br />';
$body .= date('d/m/Y h:m:s') . '<br />';
$body .= 'Nome: ' . $nome . '<br />';
$body .= 'Email: ' . $email . '<br />';
$body .= 'Mensagem:<br />' . nl2br($mensagem) . '<br />';
$body .= '</body></html>';
$email_headers = "Content-type: text/html;charset=utf-8;";
$email_headers .= "\r\nFrom:" . $email;
$retorno = mail($email_to, 'Email enviado através do formulário de contato', $body, $email_headers);
if($retorno){
$sucesso = true;
$aviso = 'Email enviado com sucesso';
}else{
$aviso = 'Erro ao enviar email, favor tentar mais tarde<br />';
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php if(!empty($aviso)): ?>
<h2><?php print $aviso; ?></h2>
<?php endif; ?>
<?php if(!$sucesso): ?>
<form action="contato.php" method="post">
<label for="nome">Nome</label> <input type="text" name="nome" id="nome" value="<?php if(isset($nome)){ echo $nome; } ?>" /><br />
<label for="email">Email</label> <input type="text" name="email" id="email" value="<?php if(isset($email)){ echo $email; } ?>" /><br />
Selecione para quem quer enviar:<br />
<select name="area">
<option value="vendas">Vendas</option>
<option value="suporte">Suporte</option>
</select><br />
Mensagem<br />
<textarea name="mensagem" cols="40" rows="10"><?php if(isset($mensagem)){ echo $mensagem; } ?></textarea><br />
<br />
<input type="submit" value="enviar" />
</form>
<?php endif; ?>
</body>
</html>