I’m working at a project right now, which is a very simple database-application. There are some php files which the user should upload. Then he calls a specific file – let it be install.html, where he should enter his root and password for accessing the server. Then a database and some tables will be created. Now, there are other files, for which this information is also needed. I thought about including a connect.php. But here’s the question: Is it possible to edit the root and password in this connect.php through another php file? If not, do you know any other user-friendly way of avoiding this problem?
I’m working at a project right now, which is a very simple database-application. There
Share
Sure you can do that. The general idea is that you ‘ve got a string with placeholders (e.g. like “{{username}}” and “{{password}}”) that you replace with the correct values with
str_replaceand then write the contents to the file withfile_put_contents.The string with the placeholders can either be declared in your script as a string or you can read it from a file with
file_get_contents. So you could have: