Trying to input to a .csv file

I have a html form that is collecting data and I am trying to capture the data into a .csv file on my server as well as send an email to my associate. I am extremely new to php but have become very familiar with a general understanding of it. I am recieving the emails still but there is no input being displayed on the .csv file. Here is what I have come up with so far, CAN ANYONE PLEASE HELP ME!

HTML

  <input type="hidden" name="recipient">

  <input type="hidden"

  name="subject" value="Marketing Kit Confirmation">

  <input type="hidden" name="redirect"

  value="a web address of your choice">

</div>
  

PHP Script

<% if ((!$NAME ) or (!$CHECKNO) && (!$EMAIL)) {
echo "Please Enter a Contact Name or a Check / Money Order Number or an 
	  Email address for Processing purpose's.
	  Thank You";
echo "<p>";
echo "Please use the 'Back' button to continue.";
echo "</p>";
echo "<a href='http://www.farpmcllc.com/marketing_kit_confirmation.htm' onclick='self.history.back();'>Back</a>";
exit;

}

$message=“Name: $NAMEnn”.“Address: $ADDRESSnn”.“City:n$CITYnn”.“State: $STATEnn”.“Zip: $ZIPnn”.“Check Number: $CHECKNOnn”.“Date: $DATESENTnn”.“Email: n”.$EMAIL;

mail("[email protected]","$subject","$message",“From:Form.$emailrnReply-to:$email”);

[b]$writetocsv = $_POST[‘NAME’] . “,” . $_POST[‘ADDRESS’] . “,” . $_POST[‘CITY’] . “,” . $_POST[‘STATE’] . “,” . $_POST[‘ZIP’] . “,” . $_POST[‘CHECKNO’] . “,” . $_POST[‘DATESENT’] . “,” . $_POST[‘EMAIL’];

$fp = fopen("/forminfo/marketingkitconfirmation.csv",“a”);

fwrite($fp,$writetocsv);

fclose($fp); [/b]

echo “

Thank you! We have recieved your submission.

”;
echo “

”;
echo $text;
echo “

Return to the Home Page”;
%>
NAME
ADDRESS
CITY
STATE / PROVINCE
ZIP / POSTAL CODE
CHECK / MONEY ORDER #
DATE SENT
EMAIL




Check to see that the webserver has the appropriate permissions to access the file you are writing to.

What have you tried to do to debug the problem?

in your fwrite() statement try doing it this way:
[php]

if (fwrite($fp, $writetocsv) === FALSE) {
echo “Cannot write to file filen”;
exit;
}
[/php]
If you get the error there (since everything else seems to work) then you know where the issue lies.

Good luck

Sponsor our Newsletter | Privacy Policy | Terms of Service