Ptsface12 Posted July 22, 2011 Share Posted July 22, 2011 Hello all, Would it be possible to have 2 files; Config.php and Install.php. On install.php, It contains 4 textbox's; Host, Database Username, Database Password, Database Name. After install is pressed, it writes to a file (config.php) with the details to connect to the database. Best Wishes, Ptsface12 Link to comment https://forums.phpfreaks.com/topic/242627-config-write/ Share on other sites More sharing options...
gristoi Posted July 22, 2011 Share Posted July 22, 2011 <?php $filename = 'test.txt'; $somecontent = "Add this to the file\n"; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> taken from php.net fwrite Link to comment https://forums.phpfreaks.com/topic/242627-config-write/#findComment-1246106 Share on other sites More sharing options...
trq Posted July 22, 2011 Share Posted July 22, 2011 Of course it's possible. Link to comment https://forums.phpfreaks.com/topic/242627-config-write/#findComment-1246150 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.