Jump to content

get mysql connection credentials from login


kurd

Recommended Posts

Hello  8)

I really need advice on how to implement a login system for a admin and sub-admin (& not registered users).

I obviously already have the admin (created during mysql installation) and i created a sub-admin using phpmyadmin (without grant privileges etc.). Is it a good method to have them enter the user and pass and have php use these to connect to the database like

$db_user=$_POST['myusername'];

$db_pass=$_POST['mypassword'];

mysql_connect($db_host,$db_user,$db_pass) or die('Could not connect: ' . mysql_error());

 

Sorry if this has an obvious answer.

I built a admin control panel that shows tables from mysql and lets you add rows and delete rows.

I'm asking how should i build the log in to this control panel? Thing is it's supposed to be for people i build websites for and they don't always know how to edit php files..

Thank you for your help.

I built a admin control panel that shows tables from mysql and lets you add rows and delete rows.

I'm asking how should i build the log in to this control panel? Thing is it's supposed to be for people i build websites for and they don't always know how to edit php files..

Thank you for your help.

Oh definitely don't give each a database connection.

 

Just register them into a database with username and password, but make sure you hash the password for security.

Access to the mysql database and access to your application are two totally different things.

 

Your application should login to the database with the mysql credentials.  In that database you should have a users table which authenticates users and determines if they have the authority to add and delete rows.

 

So your user table would be something like this

 

user_id (auto increment)

username

password (use md5 when encryption)

privileges (0 for view only, 1 for add, 2 for add and delete, or whatever you choose)

 

 

Once a user has logged in, the while they have access to the table that holds the data, they do not have access to the entire mysql database.

 

Hope this helps.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.