This project is read-only.
1
Vote

I have a form where user are filling questionnaire , When they submit special characters The doc created is corrupted

description

I have a form where user are filling questionnaire , When they submit special characters The doc created is corrupted

How can I fix this

My code
require_once 'src/PhpWord/Autoloader.php';
            \PhpOffice\PhpWord\Autoloader::register();
            
            if(isset($_POST['submit_docs'])){
            $companyname= $_POST['companyname'];
                        // Creating the new document...
            $phpWord = new \PhpOffice\PhpWord\PhpWord();
                        // Adding an empty Section to the document...
            $section = $phpWord->addSection();

                        $html .= '<ul><li>Company Name and Address : '.$_POST["companyname"].' </li></ul>';
                                    \PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);
            $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
            $objWriter->save('questionnaire/DMKSA_Questionnaire_'.$arr[0].'.docx');
Error
Warning: DOMDocument::loadXML(): StartTag: invalid element name in Entity, line: 1 in /home/iclock/public_html/test/src/PhpWord/Shared/Html.php
This happens only when special characters like '<' is being submitted

Any leads on this

comments