How to choose the database on login

Asked

Viewed 64 times

-1

I am developing a business management website, and for each company I will make a separate database so that there is no delay but queries and although a company does not see the data of another company, the question is how do I make this selection of which database connect at the time of login? I am using Mysql, Xampp...

att

Alexandre

  • Is using PDO or some specific class (function) in your code?

  • PHP, Bootstrap, Jquery and nothing else.... simple connection for now. Mysql_connect()

  • Boy, it’s a one-time login page for all companies?

  • Yes, a single page for all of them

2 answers

0

  • Right. I already use Mysqli_connect(), but how to select the database at the time of connection, when it pulls inputs (DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME) as I put the dynamic db_name, since for example, if put in the login screen 3 inputs, CNPJ,user and password, CNPJ being the identifier of which bank I will use...

  • This, at the time of login, when instantiating the connection you say which bank you want and ready :)

0

Solved personal, I created a master database that contains the company data and tbm, the name of the respective database of each one, when logging in I call the name of the database and add in $_SESSION[], then in the connection variable mysqli_connect(), thank you all.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.