Jump to content

Write Form Data To File.....Help Please


CreatureOfHabit

Recommended Posts

I am looking for a way to write data from a Form to a file that i could later access and fill in the form again.
I have an online application form that will email my boss the data when submitted:

foreach ($_POST as $Field=>$Value)
$MsgBody .= "$Field:  $Value\n\n";

The problem is that the boss doesn't like the way that it is formatted and would prefer to see the information in a form (identical to the form the user fills out).  Because the form has approx 30 fields, i thought it might be easier to write the data to file instead of storing it in a DB.
Any help would be appreciated.

Creature
Link to comment
Share on other sites

create a multidimensional array...each element contains a subarray that contains all of your items...then just serialize it and save it to the file.

[code]<?php
$formresults = unserialize(file_get_contents("formresults.dat"));

$formresults[$clientname_or_some_other_identifier] = $_POST;

$open = fopen("formresults.dat", 'w');
fwrite($open, serialize($formresults));
fclose($open);
?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.