• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

HTML form to a text document?

Hey guys,

I hope someone can point me in the right direction.

I need to know if it's possible to create an html page form, laid out with text fields and text boxes. Once the user inputs information in these fields, is it possible for a submit button to process this information and lay it out in any form of a text document for records?

I have quite a broad understanding of html, and i know its possible to send emails, but i've never heard or come across this before. It needs to be totally dedicated as otherwise i would script something in php.

Thanks for your help.
  • 2
1 Solution
Would help to know what server side language you're using (php/asp/VB/etc).

A quick php example assuming you have Name: Phone: Comments:

Have your form action run a php script like this:

$filename = //put the filename to write to here
$name = $_POST[currentFile];
$phone = $_POST[newText];
$comments = $_POST[prefix];
$textToWrite = "$name\n$phone\n\n$comments";
$fp = fopen($filename, "a") or die("Can't open $filename try again later");
fwrite ($fp, stripslashes($textToWrite));

I'm not sure what the equiv in VB/ASP/.NET would be, but sure you could find it easy enough if you need it.
Arka3LAuthor Commented:

Thanks for the effort, but please read my question more clearly. I'm asking if its possible to do it in html, also i stated that I need to be able to do this without running any server.

Is it possible, yes or no, for a user to create a form made in html format, that will post the inputted information to a text document. If you can make emails, surely there is a way to post to a text file.
No, there is no way to do that with html alone.  You have to use a server side language to access and write to files.

There is no doubt you need to use a server-side code for it. However, if your only concern is the form to be a .html file, then you can get around this. You can tell your web server (for example IIS) to process the .html files as if they were .php files. For that, you must go to Control Panel > Administrative Tools > Internet Information Services. Then you should browse to your web site, right click its name, choose Properties, Press the "Configuration..." button , press Add button, and fill the form like this:

Executable: (here you should browse to the PHP engine, it is possibly in C:\PHP and its name is php-cgi.exe if you are using the CGI version, or php5isapi.dll if you are using PHP 5 i ISAPI mode. If you have problem with this step, I can help you on your request.)
Extension: .html  (or  .htm  if you prefer)
All vers (selected)
Limit to: (dont select it)
Script engine (checked)
Check that file exists (no need to check it)

And press OK. Then paste the php code inside the html file but save it as pagename.htm and then test it online.
Hope it helps

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now