
January 3rd, 2013, 07:52 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 1
Time spent in forums: 1 h 2 m 58 sec
Reputation Power: 0
|
|
|
Send email and download the file at the same time
The idea is I know the data of those who downloaded it so I can have a control.
WANT A SCRIPT READY NOT WANT TO KNOW IN AID Q'm missing.
I have a download link that is caught on the list, which calls a form that the User must complete to trigger the download. The idea is to trigger the download when the guy pressing the submit.
I'll show you how I did
this is the page of the form
Code:
<?php require_once("settings.php"); $id = $_GET['id']; $list_files = ""; //string onde todos os registros são anexados $mysql = mysql_connect($db_host, $db_user, $db_password); mysql_select_db($db_name, $mysql); $result = mysql_query("SELECT * ,DATE_FORMAT(Data, '%d/%m/%Y') Data FROM $table_name WHERE id = $id"); // selecionando o tabela e formatando a data de forma legivel e tendo uma condição para o id while ($row = mysql_fetch_array($result)) { $id = $row['id']; //Ele salva o ID, que permite reconhecer uma linha $url_img = $row['File']; $nomedoarquivo = $row['nomedoarquivo ']; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <meta name="description" content="#" /> <meta name="keywords" content="#" /> <style type="text/css"> @import url(css/style.css); </style> <script language="javascript" type="text/javascript" src="js/mascara.js"></script> <script language="javascript" type="text/javascript" src="js/ValidaData.js"></script> <script> function AbreForm(){ document.getElementById('FORM').style.display="block"; } function FecharForm(){ document.getElementById('FORM').style.display="none"; } </script> </head> <body> <div id="container"> <div id="header"><a href="#"><img src="imagens/logo.png" class="logo" /></a></div> <div id="content"> <div class="campo-upload"> <div class="nav"><a href="index.php"> Voltar</a></div> <br /> <form method="post" action="formmail.php" enctype="multipart/form-data"> <input type="hidden" value="<?php echo $id; ?>" name="id" /> <!-- busca o id do arquivo --> <input type="hidden" value="<?php echo $url_img; ?>" name="url_img" /> <!-- busca o id do arquivo --> <fieldset> <legend>PREENCHA O FORMULÀRIO PARA EFETUAR O DOWNLOAD</legend> <label for="Empresa">Empresa:</label> <input type="text" id="Empresa" name="Empresa" size="30" /> <br /> <label for="Cnpj">Cnpj:</label> <input type="text" id="Cnpj" name="Cnpj" size="30" /> <br /> <label for="Nome">Nome:</label> <input type="text" id="Nome" name="Nome" size="30" /> <br /> <label for="Cpf">Cpf:</label> <input type="text" id="Cpf" name="Cpf" size="30" /> <br /> <label for="Endereco">Endereço:</label> <input type="text" id="Endereco" name="Endereco" size="30" /> <br /> <label for="Email">Email:</label> <input type="text" id="Email" name="Email" size="30" /> <br /> <label for="Telefone">Telefone:</label> <input type="text" id="Telefone" name="Telefone" onkeypress="mascara(this, '##-#########')" maxlength="12"size="30" /> <br /> <label for="Download">Arquivo:</label> <input type="text" id="Download" name="Download" size="30" value="<?php echo $nomedoarquivo ?>" /> <br /> <label for="Observacoes">Observações:</label> <textarea id="Download" name="Observacoes" rows="5" cols="28"></textarea> <br /> <br /> <label for="submit"> </label> <input type="submit" name="Enviar" value="Enviar e Fazer download" tabindex="2"/> <input type="reset" name="Limpar" value="Limpar"/> </fieldset> </form> <br /> </div> <div class="Reader"> <ul> <li> <img src="imagens/reader.png" width="54" height="51" class="avatar" /> <h3>Reader</h3> <p>é sempre uma ótima sugestão para quem procura um leitor para PDF de confiança.<a href="http://ardownload.adobe.com/pub/adobe/reader/win/9.x/9.3/ptb/AdbeRdr930_pt_BR.exe">Download</a> </p> </li> </ul> </div> </div> <br /> </div> <!-- fim container--> <div id="footer"> <p></p> </div> <!-- fim footer--> </body> </html> <?php mysql_close($mysql);?>
this is the page of formmail.php
when I call the formmail.php he pulls the file you saved in the format that will not open, not redirects to the list of new
I need help here in formmail
Code:
<?php $url_img = $_POST['url_img']; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$url_img"); header("Content-Type: application/pdf"); header("Content-Transfer-Encoding: binary"); echo ($url_img); $mensagem = "Empresa: ".$_POST['Empresa']." \n"; $mensagem .= "Cnpj: ".$_POST['Cnpj']." \n"; $mensagem .= "Nome: ".$_POST['nome']." \n"; $mensagem .= "Cpf: ".$_POST['Cpf']." \n"; $mensagem .= "Endereço: ".$_POST['Endereco']." \n"; $mensagem .= "Email: ".$_POST['email']." \n"; $mensagem .= "Telefone: ".$_POST['Telefone']." \n"; $mensagem .= "Download: ".$_POST['Download']." \n"; $mensagem .= "Observações: ".$_POST['Observacoes']." \n"; $mensagem .= "<br>\n Por favor, não responda a esta mensagem pois foi gerada automaticamente e tem caracter informativo apenas.<br>\n"; $headers = "MIME-Version: 1.1\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "Content-type: text/html; charset=utf-8\n"; $headers .= "X-Priority: 1\n"; $emailsender = "getrojob@gmail.com"; //email de quem vai receber $emaildestinatario = "getrojob@gmail.com"; $assunto = "Formulario de inscrição - Licitação"; if(!mail($emaildestinatario, $assunto, $mensagem, $headers ,"-r".$emailsender)) { // Se for Postfix - hospedagem linux $headers .= "Return-Path: " . $emailsender . $quebra_linha; } echo ' <script type="text/JavaScript"> alert("Seu e-mail foi enviado com sucesso. Obrigado"); location.href="index.php" </script> '; ?>
|