Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/09/2014, 12:03
dgrebiere
 
Fecha de Ingreso: septiembre-2014
Mensajes: 4
Antigüedad: 9 años, 7 meses
Puntos: 0
Descarga de Archivo al enviar Formulario

Queria saber como hacer para que una vez que se completen los datos de un formulario y accionar el envió del mismo automáticamente, luego de dicha validación de los datos completados, permita descargar un archivo.zip. (adjunto código php, faltaria el código de descarga del .zip)

Muchas gracias
Gastón
pd. este es mi primer consulta, CC si no es la manera de hacerlo, pido disculpas.



<?php
# request sent using HTTP_X_REQUESTED_WITH
if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) AND ($_POST['url']=='')){
if (isset($_POST['name']) AND isset($_POST['email']) AND isset($_POST['message'])) {
$to = '[email protected]'; // Change it by your email address
$subject='Contact from Identity';
$name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$message='';
$phone = $_POST['phone'];
if(!empty($phone)){
$message='Phone: '.$phone.'<br><br>';
}
$message .= filter_var($_POST['message'], FILTER_SANITIZE_STRING);

$sent = email($to, $email, $name, $subject, $message);
if ($sent) {
echo "<div class='content-message'> <i class='fa fa-rocket fa-3x'></i> <h2>Email Sent Successfully</h2> <p>Your message has been submitted.</p> </div>";
} else {
echo "<div class='content-message'> <i class='fa fa-times fa-3x'></i> <h2>Error sending</h2> <p>Try again later.</p> </div>";
}
}
else {
echo 'All Fields are required';
}
return;
}

/**
* email function
*
* @return bool | void
**/
function email($to, $from_mail, $from_name, $subject, $message){
require 'PHPMailer/PHPMailerAutoload.php';

$mail = new PHPMailer;
$mail->From = $from_mail;
$mail->FromName = $from_name;
$mail->addAddress($to, 'Identity'); // Add a recipient
$mail->addCC(''); //Optional ; Use for CC
$mail->addBCC('');//Optional ; Use for BCC

$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML


//Remove below comment out code for SMTP stuff, otherwise don't touch this code.
/*
$mail->isSMTP();
$mail->Host = "mail.example.com"; //Set the hostname of the mail server
$mail->Port = 25; //Set the SMTP port number - likely to be 25, 465 or 587
$mail->SMTPAuth = true; //Whether to use SMTP authentication
$mail->Username = "[email protected]"; //Username to use for SMTP authentication
$mail->Password = "yourpassword"; //Password to use for SMTP authentication
*/

$mail->Subject = $subject;
$mail->Body = $message;
if($mail->send())return true;

}
?>