| Current Path : /home/baheco/public_html/pag/ |
Linux sd-1582531-l.dattaweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 |
| Current File : /home/baheco/public_html/pag/enviar-contacto.php |
<?php
require_once '../captcha/ReCaptcha.php';
require_once '../captcha/RequestMethod.php';
require_once '../captcha/RequestParameters.php';
require_once '../captcha/Response.php';
require_once '../captcha/RequestMethod/Post.php';
require_once '../captcha/RequestMethod/Socket.php';
require_once '../captcha/RequestMethod/SocketPost.php';
if(isset($_POST['nombre'])){
$nombre = $_POST['nombre'];
}
if(isset($_POST['apellido'])){
$apellido = $_POST['apellido'];
}
if(isset($_POST['empresa'])){
$empresa = $_POST['empresa'];
}
if(isset($_POST['email'])){
$mail = $_POST['email'];
}
if(isset($_POST['mensaje'])){
$mensaje = $_POST['mensaje'];
}
if(isset($_POST['correo'])){
$correo = $_POST['correo'];
}
if(isset($_POST['g-recaptcha-response'])){
$captcha = $_POST['g-recaptcha-response'];
}
$clave_sitio = "6LcH6ikUAAAAAHV_tywnQNX6_RMv8zx1Dvnch3E_";
$clave_secreta = "6LcH6ikUAAAAAOFGMFxGwO-xqaNQZPV3IDRKhR32";
if(!$captcha)
{
header('location: ../contacto.php?mensaje=error');
}
else
{
if($nombre != '' && $apellido != '' && $empresa != '' && $mail != '' && $mensaje != '' && $correo != '')
{
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$clave_secreta."&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
$response = json_decode($response, true);
if($response["success"] == false)
{
header('location: ../contacto.php?mensaje=error');
}
else
{
$asunto = 'Consulta de Chemit Web';
echo $mensaje = "<html lang='es'>
<head>
<style>
td,
h1,
h2 {
font-family: arial;
}
table,
td {
border: 1px solid black;
border-collapse: collapse;
}
td {
padding: 20px;
font-size: 25px
}
</style>
</head>
<body>
<h1>Consulta desde la web de Chemit</h1>
<div>
<h3>Datos del contacto:</h3>
</div>
<table>
<tr><td>Nombre:</td><td>".$nombre."</td></tr>
<tr><td>Apellido:</td><td>".$apellido."</td></tr>
<tr><td>Empresa:</td><td>".$empresa."</td></tr>
<tr><td>Email:</td><td><a href='mailto:".$email."'>".$email."</a></td></tr>
</table>
<div>
<h2>Mensaje</h2>
</div>
<table>
<tr><td>".$mensaje."</td></tr>
</table>
</body>
</html>";
$destinatario = $correo;
//$destinatario = "gimenezpgabriel@gmail.com";
$headers = "MIME-Version: 1.0"."\r\n";
$headers .= "Content-type: text/html; charset=UTF-8"."\r\n";
$headers .= "To: <".$destinatario.">"."\r\n";
$headers .= "From: Chemit Web <".$destinatario.">"."\r\n";
mail($destinatario, $asunto, $mensaje, $headers);
header('location: ../contacto.php?mensaje=ok');
}
}
else
{
//header('location: ../contacto.php?mensaje=error');
}
}