Storing data in notepad or in ms word

In php you can store data in text file such as notepad and even in microsoft word too.

The following code will make you able to store form data(user name in my example ) in microsoft word file. It will create ms word file too that if file is not created before.

<?php
$username = $_POST['username'];
$fp = fopen("myfile.doc","a+") or exit("unable to open the file");
if($fp != null)
{
fwrite($fp,$username);
}
fclose($fp);

?>

0 comments: