| 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-presupuesto.php |
<?php
require_once("../phpmailer/class.phpmailer.php");
require_once("../phpmailer/PHPMailerAutoload.php");
require_once("../phpmailer/class.smtp.php");
if(isset($_POST['correo'])){
$correo = $_POST['correo'];
}
if(isset($_POST['nombre'])){
$nombre = $_POST['nombre'];
}
if(isset($_POST['mail'])){
$mail = $_POST['mail'];
}
if(isset($_POST['tel'])){
$telefono = $_POST['tel'];
}
if(isset($_POST['localidad'])){
$localidad = $_POST['localidad'];
}
if(isset($_POST['detalle'])){
$detalle = $_POST['detalle'];
}
if(isset($_POST['medidas'])){
$medidas = $_POST['medidas'];
}
if(isset($_POST['tipo-plano'])){
$tipoPlano = $_POST['tipo-plano'];
}
if (file_exists($_FILES['archivo-plano']['tmp_name']) || is_uploaded_file($_FILES['archivo-plano']['tmp_name'])){
move_uploaded_file($_FILES['archivo-plano']['tmp_name'], '../files/'.$_FILES['archivo-plano']['name'].'');
}
$mensaje= "<table>
<tr><td>Nombre:</td><td>".$nombre."</td></tr>
<tr><td>Localidad:</td><td>".$localidad."</td></tr>
<tr><td>Telefono:</td><td>".$telefono."</td></tr>
<tr><td>Email:</td><td><a href='mailto:".$mail."'>".$mail."</a></td></tr>
<tr><td>Detalle:</td><td>".$detalle."</td></tr>
<tr><td>Medidas:</td><td>".$medidas."</td></tr>
<tr><td>Plano:</td><td>Tipo ".$tipoPlano."</td></tr>
</table>";
function form_mail($sPara, $sAsunto, $sTexto, $sDe)
{
$email = new PHPMailer();
$email->From = $sDe;
$email->FromName = 'Baheco Web';
$email->Subject = $sAsunto;
$email->Body = $sTexto;
$email->isHtml(true);
$email->AddAddress( $sDe );
$file_to_attach = '../files/'.$_FILES['archivo-plano']['name'].'';
$email->AddAttachment( $file_to_attach );
if(!$email->send())
{
echo $email->ErrorInfo;
return false;
}
else
{
return true;
}
}
//Ejemplo de como usar:
//if (form_mail($email, "Solicitud de Presupuesto", $mensaje, $item['descripcion']))
if (form_mail($mail, "Solicitud de Presupuesto", $mensaje, $correo))
{
header("Location: ../solicitud.php?mensaje=ok");
}
else
{
header("Location: ../solicitud.php?mensaje=error");
}
?>