Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Not getting complete form data to save to text


KenThelate - 4:16 am on Oct 22, 2011 (gmt 0)


Hi,

I've been up for a couple of nights trying to get the following code to save the complete form data.

I am using the following code to save from a form survey


<?php


// Collect all the form data into an easier variable.
$form_data = ($_POST);

$timestamp = date('Y-m-d-H-i-s');
$mount_point = "c:/test";

$survey_filename = $mount_point ."/" .$form_data[':SURVEY:'] ."-" .$timestamp .".txt";

if (($survey_fp = fopen($survey_filename, "wb")) === FALSE)
{

//Could not write to flash trying internal disk
$survey_filename = "c:/test" .$form_data[':SURVEY:'] ."-" .$timestamp .".txt";
if (($survey_fp = fopen($survey_filename, "wb")) === FALSE)
{
die('FATAL ERROR: Could not save survey');
}
}

// Write form data
foreach ($form_data as $name=>$value)

{
fwrite($survey_fp, "$name=$value\r\n");
}

// close the survey text file
fclose ($survey_fp);

?>


The problem is that the code would post single response, but would only output the last response from multiple response questions, like this:

V15=8
V154=7
V155=1
V16=t


But I want to get multiple response questions to show up and they should look like this:

V15=1;3;8
V154=2;4;7
V155=1
V16=t


I'm still looking into it, but my experience with php script is limited, so please let me know if you have any hits as to what the problem might be.

Thanks in advance


Thread source:: http://www.webmasterworld.com/php/4377932.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com