HELP I can not send PDF in email from Database

0

I had a form that asked for mail and sent to a function that answered with information. Now I added a Hidden field in the form to send the path of the file via POST, but when I send it, it gives me an error:

  

Parse error: syntax error, unexpected 'Content' (T_STRING) in /home/idecap/public_html/php/mail.php on line 10

I searched but I do not give with the error, I share the code.

Función mail.php

<?php

$para = $_POST['EMAIL'];
$nombre = $_POST['id'];
$copia = "[email protected]";
$descarga = "www.idecap.org/administrar/upload/$nombre";
$asunto = "DESCUENTO ESPECIAL - APROVECHA AHORA MISMO";

$mensaje = "<html lang ='es'>"
          . "<head><meta http-equiv="Content-Type" content="text/html; charset=gb18030">"
          . "<title>Descarga el Temario con un descuento Especial</title>"
          . ""
          . "</head>"
          . "<body>"
          . "Gracias por capacitarte con IDECAP Educaci贸n Ejecutiva"
          . " para acceder al temario con el descuento del curso, da clic aqu&iacute;: </br>"
          . "<a href='$descarga'> Acceder</a>"
          ."</body>"
          . "</html>";

$cabeceras ='MIME-Version: 1.0' . "\r\n";
$cabeceras.='Content-type: text/html; charset=iso-8859-1' . "\r\n";

$cabeceras.= 'From: IDECAP Educacion Ejecutiva <[email protected]>' ."\r\n";

mail("$para,$copia", $asunto, $mensaje, $cabeceras);
?>;

And this is the part of the form:

<form id="mailchimp-subscription-form1" class="newsletter-form mt-40" method="POST" action="php/mail.php">
              <label for="mce-EMAIL"></label>
              <div class="input-group">
                <input type="email" id="mce-EMAIL" data-height="45px" class="form-control input-lg" placeholder="Tu Email" name="EMAIL" value="">
                <input type="hidden" id="id" name="id" value="<?php $row['descarga_pdf']; ?>">
                <span class="input-group-btn">
                  <button type="submit" class="btn btn-colored btn-dark btn-lg m-0" data-height="45px">Recibir</button>
                </span>
              </div>
            </form>
    
asked by David Sánchez 09.05.2018 в 01:30
source

2 answers

0
  

Parse error: syntax error, unexpected 'Content' (T_STRING)

means: I found the word "Content" without waiting for me

When you arm the message you are using double quotes inside double quotes, you have to "escape" them so that the chain is not broken (put them with a \ front)

$mensaje = "<html lang ='es'>"
      . "<head><meta http-equiv="Content-Type" content="text/html; charset=gb18030">"
      . "<title>Descarga el Temario con un descuento Especial</title>"

It would stay like this

$mensaje = "<html lang ='es'>"
      . "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb18030\">"
      . "<title>Descarga el Temario con un descuento Especial</title>"

That way the message chain is not broken.

Edit

Modified complete code (I changed some things for a local test)

#!/usr/bin/env php
<?php

$para = "[email protected]";//$_POST['EMAIL'];
$nombre = "Nombre";//$_POST['id'];
$copia = "[email protected]";//"[email protected]";
$descarga = "www.idecap.org/administrar/upload/$nombre";
$asunto = "DESCUENTO ESPECIAL - APROVECHA AHORA MISMO";

$mensaje = "<html lang ='es'>"
          . "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb18030\">"
          . "<title>Descarga el Temario con un descuento Especial</title>"
          . ""
          . "</head>"
          . "<body>"
          . "Gracias por capacitarte con IDECAP Educaci贸n Ejecutiva"
          . " para acceder al temario con el descuento del curso, da clic aqu&iacute;: </br>"
          . "<a href='$descarga'> Acceder</a>"
          ."</body>"
          . "</html>";

$cabeceras ='MIME-Version: 1.0' . "\r\n";
$cabeceras.='Content-type: text/html; charset=iso-8859-1' . "\r\n";

$cabeceras.= 'From: IDECAP Educacion Ejecutiva <[email protected]>' ."\r\n";
var_dump("$para,$copia", $asunto, $mensaje, $cabeceras);
?>;

As you will see instead of sending the mail, I show the data on the screen with var_dump(); and the result is:

$ ./stringtest.php
string(33) "[email protected],[email protected]"
string(42) "DESCUENTO ESPECIAL - APROVECHA AHORA MISMO"
string(377) "<html lang ='es'><head><meta http-equiv="Content-Type" content="text/html; charset=gb18030"><title>Descarga el Temario con un descuento Especial</title></head><body>Gracias por capacitarte con IDECAP Educaci贸n Ejecutiva para acceder al temario con el descuento del curso, da clic aqu&iacute;: </br><a href='www.idecap.org/administrar/upload/Nombre'> Acceder</a></body></html>"
string(121) "MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: IDECAP Educacion Ejecutiva <[email protected]>
"
;

So if you still have errors, the error text should be different and be somewhere else.

    
answered by 09.05.2018 / 02:11
source
0

The problem is that you are mixing double and single quotes. The correct way would be like this:

$mensaje = "<html lang ='es'>"
      . "<head><meta http-equiv='Content-Type' content='text/html; charset=gb18030'>"
      . "<title>Descarga el Temario con un descuento Especial</title>"
      . ""
      . "</head>"
      . "<body>"
      . "Gracias por capacitarte con IDECAP Educaci贸n Ejecutiva"
      . " para acceder al temario con el descuento del curso, da clic aqu&iacute;: </br>"
      . "<a href='$descarga'> Acceder</a>"
      ."</body>"
      . "</html>";
    
answered by 09.05.2018 в 02:09