I have a php website, that when you click download as ms word, it downloads the page as a ms word document, the only proplem I have is that the button is showing in the word document, how can I make it not show on the word document.
the php code to make the word document when I click download is
the html code is
<input type='submit' class='no-print' value= 'Download as MS word' name= 'submit_docs' >
First of all. You are not downloading a word document, you are giving a html document a .doc extension and changing the content-type header to trick the clients browser into downloading(or open with a document plugin) instead of displaying the document normally. (This is incredibly bad practice, there is no guarantee that future versions of MS-Word or competing wordprocessors will read those files correctly).
You should grab PHPDocX(The community version is free): http://phpdocx.com
or PHPWord : phpword.codeplex.com
to generate properly formed word documents instead.
If you absolutely insist on sending .html files to the user with an incorrect file extension http headers to trick the clients OS and/or browser into launching a potentially incompatible program/plugin to open it you can set a variable after you've set the headers: i.e $skip_buttons = true; and then just do a check before the markup for the button:
<?php if(!$skip_buttons): ?>
<?php endif; ?>
Edited by SimonForsman, 07 August 2014 - 11:53 AM.