How do I capture data in a text file from my php script?

I am 1 week into PHP and I am teaching myself. I am trying to capture my html form data into a .txt file as well as sending an email with the data to my associate. I have the email response working but I am having a heck of a time trying to also send the data into the .txt file. Can anyone help? PLEASE!

Here is the html form code followed by my PHP script.

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

<% 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”);
echo “

Thank you! We have recieved your submission.

”;
echo “

”;
echo $text;
echo “

Return to the Home Page”;
%>

Thank you in advance!
[/php]

NAME
ADDRESS
CITY
STATE / PROVINCE
ZIP / POSTAL CODE
CHECK / MONEY ORDER #
DATE SENT
EMAIL




To write to a text file, you need the following functions:

fopen();
fwrite();
fclose();

You also need to make sure that the directory you are writing the file to has writeable permissions. Do this by chmoding it to 777.

take a look at http://phpformgen.sourceforge.net/

it may not be the direct answer to your doubts, but it will teach u few things…

have phun…

Sponsor our Newsletter | Privacy Policy | Terms of Service