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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.