Jump to content


Photo

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


  • Please log in to reply
1 reply to this topic

#1 CreatureOfHabit

CreatureOfHabit
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 31 August 2006 - 10:56 PM

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

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 31 August 2006 - 11:00 PM

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.

<?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);
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users