The mechanism is like this: As ManzZup said php to perform login/register tasks. When you create a form (login or register, but i'll talk only about login), you have an attribute for form tag called "action" where you put the url for the page where data is submited. Most often page is on the same location. Lets say "perform_login.php".
When you hit submit, data from your form inputs is sent and available on that page (script). Then you perform a select on db with that values (username and password). If you have a row result then the user/pass combination is good. User is valid. Save this result in a session (with is a reference to client browser).