Help - Search - Members - Calendar
Full Version: Connecting 2 database?
The Planet Forums > System Administration > Web Hosting
ezfilehosting.com
Hi! I'm new to the scene in SM icon_smile.gif.. I need help, if you can help me. icon_redface.gif



Is it even possible to connect 2 database as 1?

What i'm trying to do is when someone register @ www.ezfilehosting.com/forum they would also be registering to www.ezfilehosting.com/a, is that even possible?

I know someone was telling me it was and I can't find that topic no more icon_sad.gif in phpdev forum..

Can someon tell me how to do it if possible?



Thank You..
phatblinkie
its possible, in a variety of ways. you really have 2 separate user databases im guessing. so this might help get your thinking in the right direction.

I think your asking for when they register on 1 of your user databases for the other system to be able to tell that they have already registered and honer thier current username./passwords etc.

so lets call one of them systems "forum" and one of them "main"

if "Main" checks the same database as what "forum" uses for its authentication then that would be easy.this operation could also be performed with the roles, reversed. (vice-versa)
you could also

write a function or 2 into both systems to insert/update both databases (assuming they are using separate databases) when a username is created/modified.(probably the easiest)
ezfilehosting.com
would this work?
CODE
$connection_one = mysql_connect("server1","user","pass");

$connection_two = mysql_connect("server2","user,"pass");



mysql_select_db("db1",$connection_one);

mysql_select_db("db2",$connection_two);



mysql_query("SELECT * FROM bla1",$connection_one);

mysql_query("SELECT * FROM bla2",$connection_two);



mysql_close($connection_one);

mysql_close($connection_two);


and I place them both where they both have database connection?

taken from
QUOTE
phatblinkie
i think that your best setup would be to use a single database for the user logins on the forum and the main site. so im guessing that since your forums are using the database established with your content management system that you would want to model your login on your main page against the database it uses.
so instead of having the 2 statement you have below you would really only probably need one, and it would likely go into whatever authencation scheme your using on your main page. you could probably look around for an API guide or on the code for the content management system your using to see what thier authentication mechanisms are. it likely queries the db, if the hash on the password matches gets a row back and then starts a php session and sets a cookie on the client pc. for your main system to use the same db to authenticate the password is one thing, for it to seamlessly integrate with the content management system is another since you would need to make sure that it does all the same processes that it does on the content management portion, else they might be able to authenticate on the main site but when they goto the forum it might want them to authenticate again. even worse, they might end up creating 2 different sessions and storing conflicting session information in the cookies which are usually somewhat defined by the domain name. ( its probably going to cause an issue since both are on the same domain in the cookie)

for the detailed responses you would likely need regarding what files to alter and sql code to use you should post your question on that content management systems message board if they have one.

another option you might wanna check out is actually justhaving thier login information sent to the same place the forum sends it,( the same scripts and same field names, etc.) then adding a peice of code to it to make it redirect to the place that it was referred from. of course you will also still need to figure out exactly how the content management system is checking to see if they are already authenticated or not, but that shouldn't be terrbly hard.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.