Connecting to PHP/MySQL

Hello! My question might be obvious to some, but I am completely new to this kind of coding (just started looking into server-side :slightly_smiling_face:)

I’m trying to build a web app using PHP and MySQL, and Auth0 for the login. How do I connect Auth0 to my MySQL database(s) so that when a customer logs in, it loads that specific customer’s dashboard info? (I don’t have anything set up yet, just trying to understand the specifics.)

Thank you so much for helping out a newbie! :slightly_smiling_face:

Hi @gg08

Welcome to the Auth0 Community!

That’s a great question. If I understand correctly, you would like to connect Auth0 to the external database and use it as a source of truth for user authentication. External databases are paid feature in Auth0, and it will be necessary to keep users’ sensitive information and customers’ dashboard info in one place. Another approach would be to keep users’ authentication for Auth0 databases and store only UsersID in an external MySQL database to receive customers’ dashboard info.

3 Likes

Thanks so muck for your answer! Yes, what I’m looking for sounds like the second option you detailed. I want to keep authentication completely on Auth0, but then when a user signs in, their user ID is linked to my MySQL database so it loads their dashboard. Does that make sense? So not their login details or something, but all their info on the dashboard. (I’m trying to make an simple idea app, kind of like Pinterest, but way simpler. So what I want is that when a customer signs in, their ID is sent to the external MySQL database, and retrieves all their “ideas” to load in the app.) Again, I know this is a very simple/common application of Auth0, but I am new to this stuff. :slight_smile:

Thank you again!

1 Like

After the user has been authenticated in Auth0, you will have the id_token, which contains information about logged user. In your PHP applications, you can call the MySQL database to retrieve data based on the, for example, client’s email address. Another crucial point in achieving this flow is informing the MySQL database about a new user. You could write an action flow to tell the external database about a new user or create a new registry in the MySQL database by your PHP application if the user wasn’t found after the initial search. I hope that will help you. :grin:

1 Like

Ok, thank you so much for that! I can go from there. :slight_smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.