Write to CSV

Write to CSV

am 18.09.2005 08:34:30 von Andy

I want to capture information from a form and write that to a CSV. Could you
give me a simple script to do it. For example how to capture email address
from a form. Thank You in advance.

Re: Write to CSV

am 18.09.2005 09:35:26 von Andy

"Andy" wrote in message
news:3MSdndBSZMHul7DeRVn-sg@rogers.com...
>I want to capture information from a form and write that to a CSV. Could
>you give me a simple script to do it. For example how to capture email
>address from a form. Thank You in advance.
>

I got it LOL.

$filename = "anything.csv";
touch ("$filename");
$fpc = fopen($filename, "a") or die ("Couldn't open $filename");
fputs($fpc,"\n$_POST[from], $_POST[email], $_POST[subject],
$_POST[message]");
fclose($fpc);

Re: Write to CSV

am 18.09.2005 10:27:41 von sumeet

Andy wrote:
> "Andy" wrote in message
> news:3MSdndBSZMHul7DeRVn-sg@rogers.com...
>
>>I want to capture information from a form and write that to a CSV. Could
>>you give me a simple script to do it. For example how to capture email
>>address from a form. Thank You in advance.
>>
>
>
> I got it LOL.
>
> $filename = "anything.csv";
> touch ("$filename");
> $fpc = fopen($filename, "a") or die ("Couldn't open $filename");
> fputs($fpc,"\n$_POST[from], $_POST[email], $_POST[subject],
> $_POST[message]");
> fclose($fpc);
>
>

there is only one problem. suppose 'subject' or 'message' contains a
comma i.e. 'Las Vegas Crime Lab, USA'.

solution
fputs($fpc,"\n\"$_POST[from]\", $_POST[email], \"$_POST[subject]\",
\"$_POST[message]\"");

sumeet shroff

Re: Write to CSV

am 18.09.2005 18:40:29 von Andy

"sumeet" wrote in message
news:dgj8ca$3pk$1@domitilla.aioe.org...
> Andy wrote:
>> "Andy" wrote in message
>> news:3MSdndBSZMHul7DeRVn-sg@rogers.com...
>>
>>>I want to capture information from a form and write that to a CSV. Could
>>>you give me a simple script to do it. For example how to capture email
>>>address from a form. Thank You in advance.
>>>
>>
>>
>> I got it LOL.
>>
>> $filename = "anything.csv";
>> touch ("$filename");
>> $fpc = fopen($filename, "a") or die ("Couldn't open $filename");
>> fputs($fpc,"\n$_POST[from], $_POST[email], $_POST[subject],
>> $_POST[message]");
>> fclose($fpc);
>
> there is only one problem. suppose 'subject' or 'message' contains a comma
> i.e. 'Las Vegas Crime Lab, USA'.
>
> solution
> fputs($fpc,"\n\"$_POST[from]\", $_POST[email], \"$_POST[subject]\",
> \"$_POST[message]\"");
>
> sumeet shroff
>
>
You are right. Thank you. I will fix it.