How to constantly copy login data from one sql database to another?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Anastasia P
    New Member
    • Jan 2011
    • 2

    How to constantly copy login data from one sql database to another?

    Is there a PHP or some sort of script that will allow me to have logins created on one database also created on another?

    My main database is using Drupal and the second is Simple Machines Forum. I need people who register for the Drupal side of the equation (the main domain) to have the same login info for the SM forum (the sub domain).

    I've read other articles about how to transfer the login information from one database to another, but I need a constant creation of any new registrations to be on BOTH databases.

    Thank you for any help with this.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    The simplest way to do this would be to run the sub-domain's query in the same script that runs the main signup code.

    Code:
    // Main domain
    $main_domain_conn = mysql_connect( 'domain.tld', 'user', 'pass' );
    mysql_query( $create_user_sql, $main_domain_conn );
    // Sub-domain
    $sub_domain_conn = mysql_connect( 'sub.domain.tld', 'user', 'pass' );
    mysql_query( $create_user_sql, $sub_domain_conn );

    Comment

    • Anastasia P
      New Member
      • Jan 2011
      • 2

      #3
      Thank you Markus!

      Now, since I'm no expert at this, where exactly would I put this code? On the database right? Or would it be on the server in one of the files?

      Thanks so much!

      Comment

      Working...