How to create a file on webserver

as you can imagine from my title I need to allow users to create a file from form. example: userinput.php which will be filled with some content. Now, I know how to to open file and write to it when that file is already manualy stored on webserver.

I thought to save user input in DB and then the record to take to create a file userinput.php and then every update of that record in db will produce rename that file.

my question once again is
how to create userinput.php on a webserver.


Just store records in the database.
You don’t need any files created or renamed.

is this a joke or what ?
Please only serious answers.

finaly I found.
Since we want to create a file, we must supply a file name and tell PHP that we want to write to the file. Note: We have to tell PHP we are writing to the file, otherwise it will not create a new file.

$ourFileName = "testFile.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");

The file “testFile.txt” should be created in the same directory where this PHP code resides. PHP will see that “testFile.txt” does not exist and will create it after running this code

I can ask same question about your post. There is no sense in it.

What’s the use of this file? Why do you need to rename files if you have all the content in the database?

userinput.php file should not be filled with user input. this file must take the content from the database and output it to a browser

Try to learn PHP a little and common ways to accomplish common tasks.

why do I need to create and edit files is my reason, one of this reasons is that I maybe want to create my simple template system where css content will be entered by a user trough form which will have two fields populated by user, one for filename.php and second field with css content.
My question was how to create a file on a web server with user input !

Really !