smy101 Posted January 15, 2007 Share Posted January 15, 2007 Ok, so I have a basic HTML form set up to be processed via "formprocessor.php""formprocessor.php" collects the user submitted data and emails it to the appropriate email address depending on which person is selected on the form.My question is this:I would like to have the data posted to a text file simultaneously in order to log each instance of the form being submitted.So, say a person fills out the following on a form:Name: John DoeEmail: [email protected]Phone: 123-456-7890Address: 123 John Doe StreetThen they select the appropriate representative to send it to via a drop-down list on the same form, so lets say they select to send it to "Bob Doe"The form would then email "Bob Doe" the collected data.I would like to have it also simultaneously post a new entry to a basic text file (or equivalent).So everytime they select "Bob Doe" it also writes a new entry with the same info to "bobdoe.txt"If they select "Jane Doe" it would write it to "janedoe.txt" and so on and so forth.Can this be done simulatenously by using the same submit button that is used to process the email script? Also, if there was a way for it to precede each new entry by a single-digit increasing number that would be great, too.Im guessing this can be done using the fopen, fwrite or something similar, but I cant get it figured out.Any help is greatly appreciated. Thanks in advance. ??? Link to comment https://forums.phpfreaks.com/topic/34199-posting-to-a-text-file/ Share on other sites More sharing options...
smy101 Posted January 15, 2007 Author Share Posted January 15, 2007 If it matters, here is the line on the html form that sends it to process the form:<form name="formname" method="post" action="/folder/formprocess.php"> Link to comment https://forums.phpfreaks.com/topic/34199-posting-to-a-text-file/#findComment-160901 Share on other sites More sharing options...
Hypnos Posted January 15, 2007 Share Posted January 15, 2007 The hardest thing will be the counter. If you ment a counter just for that file, that's much easier, but still a little complex.You want fopen and fwrite. fopen provides the "handler", then fwrite will append your text to the end of the file.http://us2.php.net/manual/en/function.fwrite.phpIf you still want to do the counter, you have to read the file as well, and search it for the previous count. It usually helps to specially mark the count (like !!32!!), so that it's easily found.http://us2.php.net/manual/en/function.fopen.phpDoing this stuff with a database is much easier. Link to comment https://forums.phpfreaks.com/topic/34199-posting-to-a-text-file/#findComment-160916 Share on other sites More sharing options...
smy101 Posted January 15, 2007 Author Share Posted January 15, 2007 Thanks, but I'm having problems with how to write the code to merge with the current function of the form.Would you, or anyone else, mind showing me how I need to write the code?I can live without the numbering thing, but I need to get the text log file set up.Thanks again! Link to comment https://forums.phpfreaks.com/topic/34199-posting-to-a-text-file/#findComment-160919 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.