How could I connect to a custom database?

I’m creating a sort of SQL web client and would like to know if it’s possible to connect to a user-supplied database, as in they enter the details and the site connects to it. I couldn’t find anything on how to connect like this, only found results for connecting to an already known database.