2
I’m making a login page where the user, when logging in index.php it goes to the.php dashboard. I was able to block access to the.php panel with SESSION, but if I access connected.php (where you have the database information) or login.php (where you have the query), I can access a blank page.
I used the following code in login2.php:
if(!$_SESSION['login']) {
header('Location: index.php');
exit();
}
If the user has not logged in, when trying to directly access the.php panel page, it is returned to index.php
I tried to do this for the connection.php and login.php, but the obvious thing is, when the user clicks on the login button, it does not exit index.php.
The login.php page and related.php is just a blank page with querys and DB-related data, but I don’t want the user to have access to them.
I tried with . htaccess but with it, the user can’t login either.
Is there any way to prevent you from directly logging in.php and connecting to.php without disrupting login and redirecting to the.php dashboard after logging in?
It worked, the.php connection page has the DB data, server, login, password, name, so I can’t use the GET method because it’s passing confidential information? Already in login.php I can use, because it is just consulting the database to check if the user and password exists?
– Lucas Fernandes
Lucas, ideally, never use the GET method to send confidential information. When sending a request with the GET method, the values will be sent through Query Strings, and your url would look like this: /login.php? usuario=fulano&password=12345. This can enable someone who shouldn’t have the credentials to discover access through the URL. This is why the recommendation is always to use the POST method.
– montedo-dev