...

View Full Version : [?] Write dynamic form array to file



buggy
02-27-2010, 01:25 AM
I have a dynamic form and need to be able to write the results to a file:

FORM:

<form action="index.php" method="post">

<fieldset>
<input type="text" name="input[]" size="30" />
<input type="text" name="input[]" size="30" />

<input type="submit" name="submit" value="Submit" />

</fieldset>
</form>

RESULT:


<textarea row="10" cols"10">
<?php
foreach ($_POST['input'] as $value)
{
$value = htmlspecialchars($value);

echo "$value\n";

}
?>
</textarea>


WRITE:

// Open file
$handle = fopen("path/to/file.txt","w");
// If successful
if ($handle) {
// Write to file
fwrite($handle, $value);
// Close the file
fclose($handle);
}

Ok so if the form had only a single basic input and the result was a simple
<?php echo "$value";?> the above write function would work but as its not it doesn't ..I've been Googling for ages now and can't seem to find an answer ..Any ideas ?

mlseim
02-27-2010, 01:33 AM
<textarea row="10" cols"10">
<?php

// Open file
$handle = fopen("path/to/file.txt","w");
// If successful
if ($handle) {

foreach ($_POST['input'] as $value)
{
$value = htmlspecialchars($value);
// Write to css
fwrite($handle, $value);

echo "$value\n";
}
// Close the file
fclose($handle);
}

?>
</textarea>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum