Sure, you know PHP's MySQL functions, but do you know how to read/write files in PHP? If not, then make sure you read this article. In it, Mitch teaches you everything you need to know to successfully work with files in PHP...
// Set the string to be written to the file $values = "Name: $fName $lName\r\n"; $values .= "Age: $age\r\n"; $values .= "Sex: $sex\r\n";
// Open the file for truncated writing $fp = @fopen("organizer.data", "w") or die("Couldn't open organizer.data for writing!"); $numBytes = @fwrite($fp, $values) or die("Couldn't write values to file!");
@fclose($fp); echo "Wrote $numBytes bytes to organizer.data successfully!";
As you can see, I've used our fopen, fwrite and fclose functions with some @ symbols to stop PHP spitting any errors if they occur. If errors do occur, then the die() function will be called and a message output before the script terminates. Alternatively, you could've added
... to the top of the file to stop any type of error being displayed. Our file, organizer.data now looks like this: