Verified:

chuck

New Member
2

Apr 21st 2013, 16:40:35

First off, you should make sure you are sanitizing all user input. Trusting the contents of $_POST can lead to all sorts of security vulnerabilities.

It sounds like what you are looking for is the PHP file_exists function.

The manual entry:

http://php.net/.../function.file-exists.php

And an example usage:

$exists = file_exists('somefile.csv');
if(!$exists) {
// create the file if it was not found
}

// your file processing continues here.

Now, that said, if you just use the fopen function on a filename that is not found, PHP will attempt to create the file. specifically:

$my_csv = fopen('somefile.csv','a');

will open somefile.csv with the pointer at the end of the file (so that if you write to the file you will not overwrite its current contents) if somefile.csv exists and, if somefile.csv is not found by PHP, will attempt to create somefile.csv automatically.

chuck

New Member
2

Apr 21st 2013, 16:27:58

So, are any old Earth General Talk members around? I played Earth with some friends from school around 1998 and at that time became hooked on the EGT forum. I went by krispy and chuck505 on the boards then.

Is this an entirely new generation of EGTers? Who would have guessed a CGI-based game from the 90s would still have a community dedicated to it nearly 20 years later? Ach, what a world.