<?php

if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])){

	$secret = '6Le_7CUTAAAAAFm9g5c5n6jwlxXd4TNRKPV8ChZc';
	$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);
    $responseData = json_decode($verifyResponse);

if($responseData->success){

$nombres = $_POST['nombres'];
$apellidos = $_POST['apellidos'];
$telefono = $_POST['telefono'];
$email = $_POST['email'];
$comentarios = $_POST['comentarios'];


/* recipiente */
$para = "info@globalcaribbeanco.com, michael.harel@meritdesigns.com";

/* subject */
$subject = "Solicitud enviada desde GLOBAL CARIBBEAN COMMODITIES Website";
/* contenido */
$mensaje = "
<center> <h1>FORMULARIO DE CONTACTOS</h1></center> 
<br><br>
<table width=\"600\" border=\"1\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\" bordercolor=\"#000000\">
  <tr>
    <th align=\"left\" nowrap><span class=\"style8\">Nombres</span></th>
    <td align=\"left\" nowrap>$nombres</td>
  </tr>
    
	
	  <tr>
    <th align=\"left\" nowrap><span class=\"style8\">Apellidos</span></th>
    <td align=\"left\" nowrap>$apellidos</td>
  </tr>
	
	
		  <tr>
    <th align=\"left\" nowrap><span class=\"style8\">Telefono</span></th>
    <td align=\"left\" nowrap>$telefono</td>
  </tr>
	
  <tr>
    <th align=\"left\" nowrap scope=\"row\"><span class=\"style8\">e-mail</span></th>
    <td align=\"left\" nowrap>$email</td>
  </tr>
  
  <tr>
    <th align=\"left\" nowrap scope=\"row\"><span class=\"style8\">Comentarios</span></th>
    <td align=\"left\" nowrap>$comentarios</td>
  </tr>

</table>
";
/* Para enviar HTML en el mail */
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* de donde viene el email  */
$headers .= "From: $name <$email>\r\n";

/* and now mail it */
if (!mail($para, $subject, $mensaje, $headers)){
 	echo "ERROR: CORREO NO ENVIADO";
}

}else{
	header("Location:contactos.php?err=1");
}

}else{
	header("Location:contactos.php?err=1");
}

?>
<html>
<head>
<title>Gracias por su Solicitud</title>
<meta http-equiv="refresh" content="4;URL=index.php">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style>

*{
	margin: 0; padding:0;
	}

.gracias {
	
	font-family:Arial, Helvetica, sans-serif;
	color:#01406D;
	font-size:60px;
}

.text {
	
	font-family:Arial, Helvetica, sans-serif;
	color:#01406D;
	font-size:40px;
}

.top {
	margin:0 auto;
	background-color:#EEE;
	height:90px;
	margin-bottom:20px;
	padding-top:20px;
	padding-bottom:20px;
	text-align:center;
}

</style>

</head>
<body>
<div class="top"><a href="index.php"><img src="images/logo.png" width="234" height="99" border="0"></a></div>
<div class="gracias" align="center">Gracias por su Solicitud,</div>
<div class="text" align="center">le responderemos lo mas pronto posible </div>
</body>
</html>