View Single Post
  #9 (permalink)  
Old Nov 8th, 2006, 14:13
pietrom pietrom is offline
New Member
Join Date: Nov 2006
Location: Italy
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Submit form results to file/folder

I cannot use a DB for many reasons.

This code should be closer to the right solution, but it does not work, yet:

HTML: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"/>
    <title>Test</title>
  </head>

  <body>
    <form enctype="text/plain" method="POST" name="TestForm" action="form_output.txt">
      <p />
      Input anything: <input type="text" name="anything" value="Default"/> <br />
      <input type="submit" value="OK" name="submit"/>
    </form>
    <?php
      if ($_POST['submit']=='OK')  {
        $fh = fopen("form_output.txt", 'w');
        fwrite($fh, $_POST['anything']);
        fclose($fh);
      }
    ?>
  </body>
</html>

All I need is the form contents on a local file (in the same directory where the html/php file is)...
Reply With Quote