I've been doing database connectivity for quite a while and now I need to use a txt file and it's cornfusing. All I'm trying to do is write a small installation program and have the user enter database information into a form. The database file to be updated looks (similar) to this:
<?
$dbhost = "localhost";
$dbuser = "username";
$dbpass = "password";
$dbname = "database_name";
?>
I can open files and write to files but I'm having a hard time searching for text and replacing with form field inputs. Also, once the file is modified, my search criteria becomes invalid (if we try to update the file a second time).
What is the best method for updating a file like this (using a form field). Can you possibly search and replace $dbuser (*) meaning, just give me $dbuser and everything after it on the line?
I've searched and tried a lot of resources, just can't seem to get this.
Thanks