Link to home
Start Free TrialLog in
Avatar of socross
socrossFlag for United Kingdom of Great Britain and Northern Ireland

asked on

PHP File Management

HI

Im creating a form which collects user details (name and email), it then fires off some emails and writes the details to a csv file for download at a later date.

The csv file will be added to for a week and then downloaded then a new file will be created.

If multiple users try to open the file and append to it will there be issues???

Any suggestions??

-s-
Avatar of m00003643
m00003643

Like you suspected, you will get an exception if multiple users try to write to the same file concurrently.

If you want to allow this type of behavior, try the following:
When a user submits a form, fire off your emails like normal, but write the details to a temporary csv (or table for that matter).  Then create a cron job that appends all of the temporary csv's to your main csv every 10/15/20 minutes.

This will insure that no user is ever writing directly to your main csv, which will make it open for writing by the cron job at all times.  Alternatively (if you don't expect a large amount of user submissions), you could simply wait until your weekly reset and append all the separate submissions at that time.
Just use a database... mysql print out your data as a csv later...
Avatar of socross

ASKER

I would want to use data base but there could be issues with the server the site is run off.

If i create unique files for each submission, how would i use php to open all those files and append them to one main csv file which i could then store in a different location on the server.

thanks

-s-
ASKER CERTIFIED SOLUTION
Avatar of m00003643
m00003643

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
* closedir($dh) should also be closedir($d);

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: m00003643 {http:#20835755}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

cyberwebservice
Experts Exchange Cleanup Volunteer
Forced accept.

Computer101
EE Admin