My aim: Create a button (or hyperlink) which generates a word document on click.
Below is the code I have created, but it's not working. No errors shown. I'm aware PHP is a server side scripting language, so I think it has something to do with that.
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
function createReport() {
$fp = fopen("report.doc", 'w+');
$str = "This is the text for the word file created through php programming";
fwrite($fp, $str);
fclose($fp);
return false;
}
</script>
Hyperlink:
echo '<a href="#" onclick="createReport();">Generate</a>';