View Full Version : write out from form as 1.txt, 2.txt, 3.txt
jmituzas
05-26-2010, 02:24 AM
have a working php form but I need the form to fopen ("w+") to a text file (1.txt)
And the next time on form submission i need it to save as 2.txt, then 3.txt ...
I suppose this is done with the count function, but don't know enough about php to beable to figure it out.
Also how can I view these pages, (trying from a flash player) in the order of 1.txt, 2.txt, 3.txt?
or even in php view as 1.txt and click a button then will be 2.txt, then 3.txt
Any help with any part of this will be greatly appreciated. This has been an ongoing hair-pulling trying to help a friend type experiencing for over a year now, and the deadline is approaching soon.
Thanks in advance,
Joe
alexjewell
05-26-2010, 09:36 PM
I suggest using a MySQL database. If you don't have the luxury of a database, you could write the number of the next text file in another text file. For example, say you have txtNum.txt, and it starts with the number 1 in it. PHP opens the file, reads the 1, makes 1.txt, then writes over the 1 with a 2 in txtNum.txt for next time. Then, next time, it will take the 2 out and go through the process again.
If you have a database, though, you could eliminate the use of read/write text files altogether and just store values in an easier and more organized fashion.
bluewalrus
05-27-2010, 08:11 PM
Similar solution here might need a little altering:
http://www.dynamicdrive.com/forums/showthread.php?t=53867
If you have questions about it post them here.
Actually that will need a bit of altering... I'll post something in a bit that will output the file as well.
jmituzas
05-28-2010, 02:58 AM
I can already get it to write the data from the form in the sequence of 1.txt 2.txt 3.txt but what i need is for a count function to work ( can't get the fucntion to work correctly yet) to count the files in the directory, then add them to the script to display 1.txt, 2.txt, 3.txt and so forth.
That is what is driving me mad! Please give me an example in your response I am still learning php.
Thanks for your responses!
jmituzas
05-28-2010, 03:13 AM
Ah think i may have come up with something:
$add_script =add_script.txt
$txt = txt_name.txt
write from form to 1.txt, 2.txt, 3.txt at same time followed by $add_script append filename 1.txt to $txt
so I would end up with the txt_name.txt looking something like
some script followed by 1.txt
some script followed by 2.txt
think this may work, some work but maybe... will let you guys know.
Thanks again.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.