Connection to MySQL Database & to another Database to Login
Posted: Mon Jan 12, 2015 12:46 pm
So, as a new PHP Developer, I am trying to sort things out in my head and I need to try to make sense. If someone can guide me, I would surely appreciate it.
In my company's case, we have a web page called Login_Page.php that POSTs the "username" and "password" to the next web page which is the Check_Login.php page. We have an include() statement at the beginning of the check_login.php page that takes care of the connection to the MySQL database.
(1) Login_Page.php - Calls Check_Login.php
(2) Check_Login.php - includes dbConnect.php
Check_Login runs a SQL statement and looks for the username and password from a different database called "claimsweb".
dbConnect.php maintains the connection to the MySQL database and sets up the webpage's appearance.
Question # 1:
I do not understand the constant need for the statement, include("dbConnect.php"); to be included on every web page. Is this a necessary thing since there is no persistent database connection?
Question # 2:
The previous developer puts the username and password in for access to the MySQL database into the code. Isn't this wrong to do this? I mean, anyone reading the code can see these things.
In my company's case, we have a web page called Login_Page.php that POSTs the "username" and "password" to the next web page which is the Check_Login.php page. We have an include() statement at the beginning of the check_login.php page that takes care of the connection to the MySQL database.
(1) Login_Page.php - Calls Check_Login.php
(2) Check_Login.php - includes dbConnect.php
Check_Login runs a SQL statement and looks for the username and password from a different database called "claimsweb".
dbConnect.php maintains the connection to the MySQL database and sets up the webpage's appearance.
Question # 1:
I do not understand the constant need for the statement, include("dbConnect.php"); to be included on every web page. Is this a necessary thing since there is no persistent database connection?
Question # 2:
The previous developer puts the username and password in for access to the MySQL database into the code. Isn't this wrong to do this? I mean, anyone reading the code can see these things.