How to create numerical order PHP documents?

Alright,

I have a form to submit that I want to create a PHP document, but with a specific name.

Pretty much, I want it so when the first person submits the form, 1.php is created, then the second person submits and it creates 2.php, but does anyone have any ideas on how to do this?

Thanks.

Well, you can do that many many ways. First, the easiest is to just user the PHP Object functions.
You can start the PHP Object like this:
obj_start();

Then, echo your data for the page in whatever way you want, something like this:

echo “”;
echo “This is my page!”;
echo “this is for user #” . $_POST[‘user_number’];
echo “”;

Lastly, close the PHP Object and store it in the file…
$filename=“somefolder/” . $_POST[‘user_number’] . “.php”;
file_put_contents($filename, ob_get_clean());

NOTE: This is not a tested program, just a sample of how you would use the PHP-Object functions…
You start it, fill it with data and then write it out… Also, if you are creating a webpage that you are going to use in another page, you may have to add headers for the HTML. You were not clear on what you really wanted to do with the final file. So, you can do it this way, but, you have to be careful on what you put inside the file depending on how you want to use it. Hope that make sense and hope it helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service