Web Form to CSV not working

Hiya,

Sorry for this being my first post, but I found the forum and hopefully you guys might be able to help me.

I’m trying to get a web form to append a csv file on an ftp server every time someone submits the form on a website. I’ll put my code here:

[php]<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = ‘e-mail subject’;

// Your email address. This is where the form information will be sent.
$emailadd = $_POST[‘email’];
$emailadd2 = ‘email address that will be CC’d’;

// Where to redirect after form is processed.
$url = ‘thank you page’;

// Makes all fields required. If set to ‘1’ no field can not be empty. If set to ‘0’ any or all fields can be empty.
$req = ‘0’;

$fp = fopen(‘physical file location on ftp server’, ‘a’);

fwrite($fp, ‘"’ . $_POST[‘First_Name’] . ‘","’ . $_POST[‘email’] . ‘"’ . “\n”);

fclose($fp);

// --------------------------Do not edit below this line--------------------------
$text = “Results from form:\n\n”;
$space = ’ ';
$line = ’
‘;
foreach ($_POST as $key => $value)
{
if ($req == ‘1’)
{
if ($value == ‘’)
{echo “$key is empty”;die;}
}
$j = strlen($key);
if ($j >= 20)
{echo “Name of form element $key cannot be longer than 20 characters”;die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ’ ‘;}
$value = str_replace(’\n’, “$line”, $value);
$conc = “{$key}:$space{$value}$line”;
$text .= $conc;
$space = ’ ';
}
mail( $emailadd, $subject, $text, ‘From: ‘.$emailadd.’’);
mail( $emailadd2, $subject, $text, ‘From: ‘.$emailadd2.’’);
echo ‘’;
?>[/php]

[code]

Contact Information
First Name*
Last Name*
E-Mail  
   
Address State AL AK [/code]

Many thanks if you can help me.

Are you getting errors? I can’t tell if this is your actual code or if it’s modified for the forum e.g.

[php]$fp = fopen(‘physical file location on ftp server’, ‘a’); [/php]

Hi,

I’m not getting any errors, and I did modify the code for the forum.

Can you post the actual code?

Is ‘physical file location on ftp server’ an FTP URL? e.g. ftp://ftp.domain.com/path/to/file.csv

Sponsor our Newsletter | Privacy Policy | Terms of Service