Page 1 of 1

sending form data into word document

Posted: Fri Dec 04, 2009 6:28 am
by londoneagle
Hi all,

I have online application form where students fill all the details and the data is delivered into an email address. All this is working just fine. Now what I wants is, the data to appear in the Application form (word document). So lets say when the student fills the online form via website, the details appears on the Application form so that when we print from the college it gets printed as if the student filled in the application form.

I tried using the word document to have a send button on the word document itself but it had security issues + complication for the user(to enable macro stuff) so that option is not practical...

Any suggestion please...


While surfing around, I found a quality web hosting provider you might like. You can get to it using the link below. http://www.arvixe.com/586.html

Re: sending form data into word document

Posted: Fri Dec 04, 2009 7:22 am
by Marinusjvv
Do you wish to take the details from your database and fill it in a Word doc? I have a method, but it's rather long..

Re: sending form data into word document

Posted: Fri Dec 04, 2009 7:23 am
by Marinusjvv
Well the method i use can take info from either your form or your database. Not from email. Let me know?

Re: sending form data into word document

Posted: Fri Dec 04, 2009 7:24 am
by londoneagle
thx for the quick response... I have access to only mssql database as my hosting is on .net

Re: sending form data into word document

Posted: Fri Dec 04, 2009 7:26 am
by Marinusjvv
Ok well let me explain this.. It's going to take a while.

Re: sending form data into word document

Posted: Fri Dec 04, 2009 7:26 am
by londoneagle
is that good ?

Re: sending form data into word document

Posted: Fri Dec 04, 2009 7:48 am
by Marinusjvv
Basically, you create a template in Microsoft word, with all the headings, etc, And use keywords in the document where you need to replace the words with user's info, for example- User name : User_Name.

When saving the document, select Web page (*.htm) from the Save as Type drop down. Then save it, obviously.

In your php file you do the following:

Code: Select all

// opens the file you created
$hlines = file("filename.htm");
// creates a new word document
$handle = fopen("C://Newdoc.doc","w+");
// here you replace all the keywords with user's information
foreach($hlines as $hline_num => $hline)
{
    $hline = str_replace("User_name",$_REQUEST["User_name"],$hline);
        $hline = str_replace("User_tel",$_REQUEST["User_tel"],$hline);
        // etc
        fwrite($handle,$hline."\n");
}
It then creates the file at the destination you chose earlier (C://Newdoc.doc)

Re: sending form data into word document

Posted: Fri Dec 04, 2009 7:50 am
by Marinusjvv
Well the example i gave uses info from a form. You'll have to adapt it if your using a database, obviously.

Re: sending form data into word document

Posted: Tue Dec 08, 2009 4:33 am
by londoneagle
Hi,
Thanks for your tip but I cant seem to figure out the solution.

What I have now is an Application form (word 2007) and "apply online form" (html for form and php to send to an email)... these two are seperate.... students can either apply online (which comes via email) or download the word form fill up and send it to us.

.... the applyonline comes in an email format... and when we print, it does not look very credible.. so what we want is, the student details sent via online to be printed on the word document ... or a page similar to the word document rather than just the email format...

Available technologies I have is asp.net, php, word 2007 mssql 2008 and html obviously ...

many thanks...