Writing Form Output to a Comma Delimited File 
Author Message
 Writing Form Output to a Comma Delimited File

I am trying to collect input from "php-data-entry-form.php" and output
the entries to a text file (output.txt) using "php-data-output.php".

The file, output.txt, is created but I get nothing but spaces and a null.
Each subsequent entry is appended but I need a newline between entries.

As if this isn't enough, I need the output to be in a comma delimited file.
Arrrrrrrrrrrrrrrgh!

Below are my files:

php-data-entry-form.php:

    <html>
      <head>
        <title>Data Entry Form</title>
      </head>
      <body bgcolor="#FFFFFF" text="#000000">
        <form method="post" action="php-data-output.php">
          <p>
            Name: <input type="text" name="name"><br>
            DOB: <input type="text" name="dob"><br>
            Occupation: <input type="text" name="occupation"><br>
            <input type="submit" name="Submit" value="Submit">
            <input type="reset" name="Reset" value="Reset">
          </p>
        </form>
      </body>
    </html>

php-data-output.php:

    <HTML>
      <HEAD>
        <TITLE>Data Output</TITLE>
      </HEAD>
      <BODY>
        <?

        $out = fopen("output.txt", "a");

        if (!$out) {
            print("Could not append to file");
            exit;
        }

        fwrite($out,"$name\t");
        fwrite($out,"$dob\t");
        fwrite($out,"$occupation\t");
        fwrite($out,"$REMOTE_ADDR\n");
        print("Thanks for registering");

        fclose($out);

        ?>
      </BODY>
    </HTML>



Fri, 05 Aug 2005 07:26:39 GMT  
 Writing Form Output to a Comma Delimited File

Quote:

> The file, output.txt, is created but I get nothing but spaces and a null.
> Each subsequent entry is appended but I need a newline between entries.
> php-data-entry-form.php:
[...]
>             Name: <input type="text" name="name"><br>
> php-data-output.php:
[...]
>         fwrite($out,"$name\t");

Looks like yet another register globals issue, see
<http://www.php.net/manual/en/security.registerglobals.php> for your
solution.

HTH,
--
steven vasilogianis



Fri, 05 Aug 2005 07:47:42 GMT  
 Writing Form Output to a Comma Delimited File
This recommends setting "register_globals = off" which they are.

dld

Quote:
> Looks like yet another register globals issue, see
> <http://www.php.net/manual/en/security.registerglobals.php> for your
> solution.

> HTH,



Fri, 05 Aug 2005 08:16:33 GMT  
 Writing Form Output to a Comma Delimited File

Quote:

> This recommends setting "register_globals = off" which they are.

Which means you can't access the POST variables as you did in your original
post. I guess I'll just spell it out:

Change this (taken from original post):
        fwrite($out,"$name\t");
        fwrite($out,"$dob\t");
        fwrite($out,"$occupation\t");
        fwrite($out,"$REMOTE_ADDR\n");

To this:
        fwrite($out, $_POST['name'] . "\t");
        fwrite($out, $_POST['dob'] . "\t");
        fwrite($out, $_POST['occupation'] . "\t");
        fwrite($out, $_SERVER['REMOTE_ADDR'] . "\n");
HTH,
--
steven vasilogianis



Fri, 05 Aug 2005 10:07:17 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Export Clarion .DAT files to ASCII comma delimited files

2. Export Clarion .DAT files to ASCII comma delimited files

3. getting fields NOT comma delimited with commas inside

4. Parsing Comma delimited files in J

5. matching records in a comma delimited file

6. Comma delimited file problem

7. 2.01 Comma delimited ASCII file

8. Import comma delimited text file

9. VW code to read comma-delimited text files??

10. importing from a comma delimited file

11. Comma delimited file?

12. comma delimited file

 

 
Powered by phpBB® Forum Software