Php take users input write to file, and echo out the file for user to view

PHP

How do I set this up such that when a user enters his first name and last name, I write it to a .html file and then give the user a link to view the information that they have just entered?

I know I could just echo that out like I am already doing with $_POST['userfName'] after Welcome, but I just want to write to some .html file and echo this information back to the user to view(see).

{ 
        $_SESSION['userEmail'] = $_POST['userEmail']; 
        $_SESSION['start'] = time(); 
        echo "Welcome, " . $_POST['userfName'] .  $_POST['userlName'] .". A new session has been activated for you. Click <a href="sometextfile.html">here</a> to see your information.";
        echo "<br>Your session id is: ".session_id(); 
    } 

Best Answer

You want to actually generate a new HTML file for each user that logs in? That kind of defies the point of server-side scripting.

In fact, it's a bad idea security-wise to let your scripts have write access to your web server root.

What you'd want to do is link to "sometextfile.php?sessid=" or use a cookie containing their session ID, then generate that page dynamically.

If you just want to write a text file to disk somewhere, you can create a string then use file_put_contents (http://php.net/file_put_contents). This could be put in the web root, but I'm guessing that's not actually what you're trying to do.