This is going to really just be a higher-level overview...
"PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly."
When a request hits a server (like a browser asking to see a certain page), the server notes the request for a PHP file and filters that request to the PHP processor which then runs through the PHP code of the requested file(s) and executes the PHP instructions. Often times these instructions make requests to a database table to fetch information. Once all the data has been collected, the PHP processor puts everything back together to create an HTML page that then gets sent by the server back to the user agent (server to browser: here's the page you requested).
Now saving data to a database requires at least three parts: an html form that has a specified form action, a server-side script that executes the form action, and, obviously, a database. So once a user has filled in the html form and clicks submit, the form-action triggers the server-side script to execute and take the data from the HTML form, put it into the appropriate format to execute a database query (or sends that info to another script/application which does this) and this information then gets sent to the database application to execute that query and save the data.
So that's a high-level overview of what's happening.