Jump to content

html being stripped?


Go to solution Solved by Q695,

Recommended Posts

HI,

 

Relatively new to php here but experience with html & css.

 

I have recently taken over a project from somebody, and I'm trying to make some minor adjustments to a few areas (mostly aesthetic). The system as a whole works fine, and can read from/write to the databases, as well as send emails etc...

 

However I am encountering an issue which has me stuck, I have a button on my site 'compose email to user', when clicked a table is pulled from a database (ip_requests) displayed within a tinymce editor, 2 columns, 10 rows, border etc.. however when I click 'send' the table does in fact send successfully but the formatting seems to be ignored. The email arrives, containing all the information, however no border, bold, or coloured table cells.

 

It seems like there is a 'strip html' command somewhere.

 

Below is a sample of the code that produces the table within the tinymce editor;

$strHtmlOutput.= '
   
<tbody>
<tr>                                  
               $strHtmlOutput.= '<tr>                                  
                            <th>Date of Request</th>
                            <td>
'.$result['cdate'].'
                            </td>
                          </tr>
                         ';
  
  $strHtmlOutput.= '<tr>                                  
                            <th>Date Last Modified</th>
                            <td>
'.$result['mdate'].'
                            </td>
                          </tr>
                         ';                                     
    }
    
    $strHtmlOutput.='</tbody>
</table>';

There is a lot more code in the page itself, however maybe  some whizz will be able to help me based on the above code only? Excuse my ignorance in this!

 

I have lots of  'compose email to user' buttons on my sitem which allows me to send the data on screen to an individual via email, but they all do the same (strip email formatting). So this must be a global setting?

 

Any help would be appreciated.

 

Thanks in advance,

 

J

Edited by johnnys
Link to comment
https://forums.phpfreaks.com/topic/278901-html-being-stripped/
Share on other sites

The thing you posted doesn't have any HTML stripping so... can't really say. There being such a thing would explain what you're experiencing, but without the code it's anybody's guess where that's happening.

 

Follow the path the code takes, where $strHtmlOutput goes from that point to where it's put into the email. Put some echos or logging statements or something so you can find out where the HTML is being stripped.

Link to comment
https://forums.phpfreaks.com/topic/278901-html-being-stripped/#findComment-1434700
Share on other sites

wow thanks chriscloyd - this works :)

 

what exactly is that doing differently than I was? Oh I also had to change the $mail->Body from $emailcontent to $strHtmlOutput.

 

thanks very much

 

As Jessica mentioned, the original code is invalid. The first string wasn't ended, for example. This:

 

 

$strHtmlOutput.= '
   
<tbody>
<tr>                                  
               $strHtmlOutput.= '<tr>                                  
                            <th>Date of Request</th>
                            <td>
'.$result['cdate'].'
                            </td>
                          </tr>
                         ';

 

Should be:

 

 

$strHtmlOutput.= '
   
<tbody>
<tr>'; //<-- close string here
               $strHtmlOutput.= '<tr>                                  
                            <th>Date of Request</th>
                            <td>
'.$result['cdate'].'
                            </td>
                          </tr>
                         ';
Link to comment
https://forums.phpfreaks.com/topic/278901-html-being-stripped/#findComment-1435316
Share on other sites

$strHtmlOutput.= '
   
<tbody>
<tr>                                  
               $strHtmlOutput.= '<tr>                                  
                            <th>Date of Request</th>
                            <td>
'.$result['cdate'].'
                            </td>
                          </tr>
                         ';
  
  $strHtmlOutput.= '<tr>                                  
                            <th>Date Last Modified</th>
                            <td>
'.$result['mdate'].'
                            </td>
                          </tr>
                         ';                                     
    }
    
    $strHtmlOutput.='</tbody>
</table>';

 

missing a single '

$strHtmlOutput.= '
   
<tbody>
<tr>';                                  
               $strHtmlOutput.= '<tr>                                  
                            <th>Date of Request</th>
                            <td>
'.$result['cdate'].'
                            </td>
                          </tr>
                         ';
  
  $strHtmlOutput.= '<tr>                                  
                            <th>Date Last Modified</th>
                            <td>
'.$result['mdate'].'
                            </td>
                          </tr>
                         ';                                     
    }
    
    $strHtmlOutput.='</tbody>
</table>';
Edited by Q695
Link to comment
https://forums.phpfreaks.com/topic/278901-html-being-stripped/#findComment-1435318
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.