File: /home/asjudine/public_html/principal/contactenos.php
<?php
global $dbi;
error_reporting(0);
require_once("../Conectarse.php");
$sql5 = mysql_query('SELECT * FROM Usuarios order by Nombre_Completo ');
if (!$sql5) {
die('Invalid query: ' . mysql_error());
}
$row_sql5 = mysql_fetch_assoc($sql5);
$totalRows_sql5 = mysql_num_rows($sql5);
?>
<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags -->
<meta http-equiv="X-UA-Compatible" content="IE=8; IE=9; IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../css/estilos.css">
<style>
select{
font-size: 14px!important;
}
</style>
</head>
<body>
<?php if ($error) echo "<font color='red'>$error</font>";?>
<?php include('../headerint.php'); ?>
<?php include('../navint.php'); ?>
<h1 class="titulos">Asesoría Jurídica Prepagada - Planes</h1>
<main class="main">
<form id="formulario" enctype="multipart/form-data" method="post" name="formulario">
<div class="container">
<div class="contenedor">
<p class="subtitulo2">Por favor diligenciar todos los campos, seleccione el funcionario al cual enviará el mensaje, en caso de que requiera enviar un archivo adjunto, haga click en el botón Examinar, seleccione el archivo y si usted considera que la información es correcta, hacer click en el botón Enviar. Esta información llegará al buzón de correo del Funcionario de Interasjudinet.</p>
<hr>
<fieldset>
<div class="box">
<label for="nombre">Nombre Afiliado</label>
<input name="nombre" type="text" id="nombre" size="35" maxLength=35>
</div>
<div class="box">
<label for="direccion">Dirección Postal:</label>
<input name="direccion" type="text" id="direccion" size="50" maxLength=50>
</div>
<div class="box">
<label for="ciudad">Ciudad:</label>
<input name="ciudad" type="text" id="ciudad3" size="35" maxLength=35>
</div>
<div class="box">
<label for="telefono">Teléfono:</label>
<input name="telefono" type="text" id="telefono" size="20" maxlength="20">
</div>
<div class="box">
<label for="celular">Celular:</label>
<input name="celular" type="text" id="celular" size="24" maxlength="24">
</div>
<div class="box">
<label for="email">E-mail:</label>
<input name="email" class=mail size="50" maxlength=100>
</div>
<div class="box">
<label for="asunto">Asunto:</label>
<input name="asunto" class=text id="asunto" size="50" maxlength=50>
</div>
<div class="box">
<label for="asunto">E-mail Destino:</label>
<select name="correo" class="Estilo66">
<option value="">--SELECCIONE FUNCIONARIO--</option>
<?php
do {
?>
<option value="<?php echo $row_sql5['Cargo'];?>"><?php echo $row_sql5['Nombre_Completo']?></option>
<?php
} while ($row_sql5 = mysql_fetch_assoc($sql5));
$rows5 = mysql_num_rows($sql5);
if($rows5 > 0) {
mysql_data_seek($sql5, 0);
$row_sql5 = mysql_fetch_assoc($sql5);
}
?>
</select>
</div>
</fieldset>
</div>
<div class="contenedor">
<fieldset>
<label for="my_file">Archivo Adjunto:</label>
<input type="file" name="my_file" id="my_file" size="35">
</fieldset>
<fieldset>
<label for="asunto">Mensaje:</label>
<textarea tabindex=0 name=mensaje rows=3 cols=90></textarea>
</fieldset>
</div>
</div>
<div align="center">
<input type="submit" VALUE="Enviar" name="enviar" id="enviar" class="direcciona">
<!--<input name="button" type="button" class="boton2" onClick="history.back()" value="Volver a la página principal">-->
<input name="button" type="button" class="boton1" onClick="window.location.href='../index.php'" value="Volver">
<!--<input name="reset2" type=reset class=btn value="Borrar datos">-->
</div>
</form>
</main>
<?php include_once('../footerint.php'); ?>
</body>
</html>
<?php
//Es necesario que al menos halla una dirección de destino
$error="";
if (isset($_POST["enviar"])) {
if($_POST && isset($_FILES["my_file"])) {
//if($_POST && isset($_FILES["my_file"]))
//{/******************************************************/
$subject="Este mensaje viene desde Contactenos";
$nombre = filter_var($_POST["nombre"], FILTER_SANITIZE_STRING);
$direccion = $_POST["direccion"];
$ciudad = $_POST["ciudad"];
$telefono = $_POST["telefono"];
$celular = $_POST["celular"];
$email = filter_var($_POST["email"], FILTER_SANITIZE_STRING);
$reply_to_email = filter_var($_POST["email"], FILTER_SANITIZE_STRING);
$asunto = $_POST["asunto"];
$correo = $_POST["correo"];
$mensaje = $_POST["mensaje"];
$busca = mysql_query("SELECT cargo FROM Usuarios WHERE nombre = '".$correo."' ");
list($cargo_funcionario) = mysql_fetch_row($busca);
if($correo == "ABOGADO" || $cargo_funcionario == "ABOGADO")
{
$to = "abogados@asjudinet.com";
$direcciones["direccion1"]=$correo;
}
if($correo == "ASISTENTE DE VENTAS" || $correo == "DIRECTOR COMERCIAL" || $correo == "DIRECTOR DE HISTOSER" || $cargo_funcionario == "ASISTENTE DE VENTAS" || $cargo_funcionario == "DIRECTOR COMERCIAL" || $cargo_funcionario == "DIRECTOR DE HISTOSER")
{
$to = "ventas@asjudinet.com";
$direcciones["direccion1"]=$correo;
}
if($correo == "EJECUTIVA DE CUENTA" || $correo == "GERENTE ADMINIStrATIVA" || $correo == "JEFE CARTERA BANCOS" || $correo == "JEFE CARTERA NOMINAS" || $correo == "JEFE DE COBRANZAS" || $correo == "RECEPCIONISTA" || $correo == "PRESIDENTE SERVIASJUDINET" || $correo == "Secretaria Veeduria Ciudadna" )
{
$to = "servi@asjudinet.com";
$direcciones["direccion1"]=$correo;
}
if($correo == "SERVICIO AL CLIENTE" || $correo == "GERENTE GENERAL" || $correo == "DISER VILLAVICENCIO" || $correo == "DISER VALLEDUPAR" || $correo == "DISER BARRANQUILLA" || $correo == "DISER BOGOTA" || $correo == "DISER CALI " || $correo == "DISER FLORENCIA" || $correo == "DISER IBAGUE" || $correo == "DISER MEDELLIN" || $correo == "DISER MOCOA" || $correo == "DISER PEREIRA")
{
$to = "servicioalcliente@asjudinet.com";
$direcciones["direccion1"]=$correo;
}
//Obtener datos del archivo subido
$file_tmp_name = $_FILES['my_file']['tmp_name'];
$file_name = $_FILES['my_file']['name'];
$file_size = $_FILES['my_file']['size'];
$file_type = $_FILES['my_file']['type'];
$file_error = $_FILES['my_file']['error'];
if($file_error > 0)
{
die('Error al subir el archivo. No se adjunto ningun archivo');
}
//Leer el archivo y codificar el contenido para armar el cuerpo del email
$handle = fopen($file_tmp_name, "r");
$content = fread($handle, $file_size);
fclose($handle);
$encoded_content = chunk_split(base64_encode($content));
$boundary = md5("pera");
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From:".$email."\r\n";
$headers .= "Reply-To: ".$email."" . "\r\n";
$headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n";
$msg = "Ha llegado este mensaje desde el formulario de Contactenos de Interasjudinet\n";
$msg .= "\nNombre: " .strtoupper($nombre). "\n";
$msg .= "\nDirección: " .strtoupper($direccion). "\n";
$msg .= "\nCiudad: " .strtoupper($ciudad). "\n";
$msg .= "\nTeléfono Fijo: " .strtoupper($telefono). "\n";
$msg .= "\nCelular: " .strtoupper($celular). "\n";
$msg .= "\nEmail: " .strtoupper($email). "\n";
$msg .= "\nMensaje: " .strtoupper($mensaje). "\n";
//Texto plano
$body = "--$boundary\r\n";
$body .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: base64\r\n\r\n";
$body .= chunk_split(base64_encode($msg));
//Adjunto
$body .= "--$boundary\r\n";
$body .="Content-Type: $file_type; name=".$file_name."\r\n";
$body .="Content-Disposition: attachment; filename=".$file_name."\r\n";
$body .="Content-Transfer-Encoding: base64\r\n";
$body .="X-Attachment-Id: ".rand(1000,99999)."\r\n\r\n";
$body .= $encoded_content;
//Enviar el mail
$sentMail = @mail($to, $subject, $body, $headers);
if($sentMail) //Muestro mensajes segun se envio con exito o si fallo
{
echo"<br><br><br><center>El Formulario ha sido diligenciado. <br>Gracias por suscribirse a Interasjudinet<center>";
echo "<script>alert('La informacion fue enviada, Se revisara su solicitud lo mas pronto posible');</script>";
echo "<SCRIPT LANGUAGE='javascript'>window.location.href='../index.php'</SCRIPT> ";
/*echo "<script languaje='javascript'>window.close();</script>";*/
}
}
}
else
{
}
?>