Created
December 15, 2012 01:06
-
-
Save anonymous/4290179 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//error_reporting(0); | |
$validation = array( | |
'email' => 'Digite um e-mail!', | |
'nome' => "Digite seu nome!" | |
); | |
foreach($validation as $key => $message){ | |
if (empty($_POST[$key])){ | |
echo json_encode(array('message' => $message, 'status' => 'fail')); | |
exit; | |
} | |
} | |
$txt = "<b>Contato enviado pelo site</b><br><br>"; | |
$txt .= "Nome: " . $_POST['nome'] . "<br>"; | |
$txt .= "E-mail: " . $_POST['email'] . "<br>"; | |
$txt .= "Telefone: " . $_POST['telefone'] . "<br>"; | |
$txt .= "Check In: " . $_POST['checkin'] . "<br>"; | |
$txt .= "Check Out: " . $_POST['checkout'] . "<br>"; | |
$txt .= "Pessoas: " . $_POST['pessoas'] . "<br>"; | |
$txt .= "Reserva: " . nl2br($_POST['reserva']) . "<br>"; | |
$txt .= "<br /><br />IP: " . $_SERVER['REMOTE_ADDR']; | |
$txt .= "<br />Data&Hora: " . date('d/m/Y H:i'); | |
$txt .= "<br /><br />UserAgent: " . $_SERVER['HTTP_USER_AGENT']; | |
$headers = "MIME-Version: 1.1\n"; | |
$headers .= 'Content-type: text/html; charset=utf-8' . "\n"; | |
$headers .= 'From: [Reserva via Site] <[email protected]>' . "\n"; | |
$headers .= "Return-Path: [Reserva via Site] <[email protected]>\n"; | |
$headers .= "Reply-To: ".$_POST['nome']." <".$_POST['email'].">\n"; | |
if (mail("[email protected]", "[Contato Site]", $txt, $headers)) { | |
echo json_encode(array('message' => "Mensagem enviada!", 'status' => 'okay')); | |
} else { | |
echo json_encode(array('message' => "Houve um problema no envio do e-mail.", 'status' => 'fail')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment