Hey @gelseyland! I’m working on a small online book thing called PHP For People (inspired by Blake Watson’s excellent HTML For People), and this is the exact thing that the book will cover: the ins-and-outs of form submission and data processing/storage/retrieval (from flatfiles, so no complex and intimidating database stuff). It’ll walk you through every aspect of the process of building a simple guestbook app (which is pretty much entirely about submitting data with a form and then showing it somewhere else!). So hopefully it’ll be helpful to you and others trying to do this kind of stuff!
But, until that’s ready, I’m more than happy to help you out with this if you want to hang in there with building your own!
The answer to the question of where the data gets stored is pretty much “where you tell it to”
which probably doesn’t help much in general, but more specifically the function file_put_contents is how this is usually done. It takes two required arguments, the first being the path (with filename) where you want to save your data, and the second being the data itself.
So, for instance, let’s say you want to store your data (which we’ll say lives in a $data variable for this example) in /home/gelseyland/www/private/data.txt. You’d do this:
<?php
file_put_contents('/home/gelseyland/www/private/data.txt', $data);
?>
And that’s where your data will be saved.
Now, the other part about keeping the data secure — that’s important, and how it’s done depends on your web host. Most web hosts have a “public” directory which serves as the web root, which is where all of your HTML is served from and your PHP scripts are accessed and such. The easiest way to keep your submitted data secure is to not store it in that public web root. Instead, save it to a location outside of it, and then no prying eyes will be able to access it by guessing filenames in their browser.
With your data saved outside of the web root, you can then ensure that the only way people see it would be from a script that you control (in the web root). The script would open the file, read the data, and control what’s shown and how.
If you’d like a super basic example of a form, a PHP script that receives the data and saves it, and another PHP script that opens the data and displays it, I’d be happy to whip something up. 