MyBB Community Forums

Full Version: [NEED] Check a custom profile field in a external database.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello.

In my registry system there is a custom field, where the user must put the user name that is registered in another database, on another server.
I wanted a function that would connect to this database and check if the user actually exists at the time of registering and also when to change in the User Control Panel.

Can anyone help me?
What is the issue here? Are you facing issues connecting to remote database?
The connection should be like:
$conn = new PDO('mysql:host=192.168.1.3;dbname=TEST;port=3306','username','password');

Replace the IP with your remote db host. Assign example values as original.
Remember not to write 'hostname', it is 'host'. 'hostname' is invalid for dsn and using this will fallback to 'localhost'.

Then simple query and comparison can do the job.
(2018-04-16, 02:25 PM)effone Wrote: [ -> ]What is the issue here? Are you facing issues connecting to remote database?
The connection should be like:
$conn = new PDO('mysql:host=192.168.1.3;dbname=TEST;port=3306','username','password');

Replace the IP with your remote db host. Assign example values as original.
Remember not to write 'hostname', it is 'host'. 'hostname' is invalid for dsn and using this will fallback to 'localhost'.

Then simple query and comparison can do the job.

The only problem is that I do not know how to make it work, I understand very little of php. I know I'm asking too much and I know it's not simple to do:
1 - I have a custom field (Required in the registry and in the user profile).
2 - In this field the user has to enter his name that is saved in another database (game server).
3 - I wanted when the user typed, or when he confirmed the profile registration / update, would return an error if the name entered does not exist in the defined database.

Thank you!