Jump to content

Archived

This topic is now archived and is closed to further replies.

CreatureOfHabit

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

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.