PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 3rd, 2013, 07:52 AM
getrojob getrojob is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 getrojob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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>     ';      ?>

Reply With Quote
  #2  
Old January 3rd, 2013, 08:05 AM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,886 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 3 Days 8 h 22 m 27 sec
Reputation Power: 581
Please edit you post so it is not all on one line and use [ PHP ] tags not [ CODE ] tags (see the sticky at the top of this forum). Highlight your code then click the PHP icon. Also make sure your headers are absolutely the very first thing you output. Even a space will cause the headers to not work. There can be nothing preceding the first '<?php' on the page that outputs the headers.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Send email and download the file at the same time

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap