HTML form to a text document?

Posted on 2006-03-31
Last Modified: 2010-05-18
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.
Question by:Arka3L
    LVL 16

    Expert Comment

    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.
    LVL 1

    Author Comment


    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.
    LVL 16

    Accepted Solution

    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.

    LVL 14

    Expert Comment

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now