cosfreelance
MIS
Hi all,
I am new to progrmming and php, so apologies for the basic question.
i am writing form fields to a text file. however, i do wish to write the key names /values even if they are empty. the code i have is below, what do i change to get the form to write the field names and values?
<?php
foreach($_POST as $key => $data) {
if($key != 'required') {
if($data !='') {
$stringData .= $key.": ".$data .",";
}
}
}
$myFile = "testFile.txt";
$fh = fopen($myFile, 'a+') or die("can't open file");
$stringData = $stringData."\n";
fwrite($fh, $stringData);
fclose($fh);
?>
Thanks in advance
I am new to progrmming and php, so apologies for the basic question.
i am writing form fields to a text file. however, i do wish to write the key names /values even if they are empty. the code i have is below, what do i change to get the form to write the field names and values?
<?php
foreach($_POST as $key => $data) {
if($key != 'required') {
if($data !='') {
$stringData .= $key.": ".$data .",";
}
}
}
$myFile = "testFile.txt";
$fh = fopen($myFile, 'a+') or die("can't open file");
$stringData = $stringData."\n";
fwrite($fh, $stringData);
fclose($fh);
?>
Thanks in advance