Jump to content

mirror username password field


alohatofu

Recommended Posts

I think this is where this question should be asked. please let me know if I posted on the wrong forum.

 

I was wondering if someone could give me some guidance in mirroring 2 databases with their username and password fields only.

 

I have 2 databases that I would like to mirror with the username and password. Is it possible if so, please help.

Do i setup a script? cronjob?

 

Thank you!

Link to comment
https://forums.phpfreaks.com/topic/47726-mirror-username-password-field/
Share on other sites

Do you really want the two databases (er, username/password columns) "mirrored", or do you want the user to be able to log into both "applications" using the same information?

 

Could you just use two connections -- one to your database with the uname/pass and one to the other -- within the same script?  Use just one table for authentication.

 

Or put a line of code in each application which INSERTs the info in the other database.

 

If this sounds okay, see the PHP manual for using multiple database connections -- it'll be under mysql_connect, and you'll need a variable to keep track of which connection.

I really want the fields username/password to be mirrored. I have 2 applications (one is xoops) and another custom application.  I want them to be able to use the username/password from xoops on the new application and vice versa without having to create an account on the custom application.  I already have the username and password field and authentication method for the custom application (able to login if I create the account).

 

I've looked at the manual but unable to get anywhere. I'm a newbie at mysql and php. any help will be greatly appreciated.

Why don't you just run an extra query on an CREATE/UPDATE of a particular database?

 

For an xoops CREATE or UPDATE:

INSERT INTO users (username,password) VALUES ('xxx','yyy');
INSERT INTO customapp.users (username,password) VALUES ('xxx','yyy');

UPDATE users SET password='zzz' WHERE username='xxx';
UPDATE customapp.users SET password='zzz' WHERE username='xxx';

 

Reverse it for the other way around.  You'll need permissions on both databases.  You'll also need to check for the presence of a pre-existing username on the opposite database previous to INSERTing any values.

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.