You don't necessarily need to store this information in a database, you could just write the information to a file as well. It really depends on whether or not you have access to a database, and what database.
If you do, and it is the most common companion to PHP (MySQL), then I would look at the PHP PDO reference to learn how to read/write data to a database.
Otherwise, look at the filesystem functions to see how to write information to a file. I would recommend looking at the fopen(), fread(), and fwrite() functions in particular.