Uutiset:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu
Advertisement:

transferring usernames, passwords & emails to SMF.

Aloittaja cellDamage, maaliskuu 12, 2005, 08:51:47 AP

« edellinen - seuraava »

cellDamage

I've got a database with passwords (not md5'ed as of yet), usernames and emails that i want to copy over to the SMF users database.

how would i do a mass copy over? and md5 the passwords on the way so SMF likes them?
Also if it finds duplicate usernames, i want it to just report it and stop that record being copied.

Oldiesmann

#1
<?php
include_once('/path/to/SSI.php');
$users = array();
$query db_query("SELECT username, password FROM table ORDER BY username ASC"__FILE____LINE__);
while(
$stuff mysql_fetch_assoc($query))
{
    
$query1 db_query("SELECT memberName FROM {$db_prefix}members WHERE memberName = '$stuff[username]'"__FILE____LINE__);
    if(
mysql_num_rows($query1) == '1')
    {
        echo 
'Skipping duplicate username ' $stuff['username'] . '...';
        continue;
    }
    else
    {
        
$users[] = $stuff['username'];
        
$query2 db_query("INSERT INTO {$db_prefix}members (memberName, password) VALUES ($stuff['username'], md5($stuff['password']))"__FILE____LINE__);
    }
}
?>


Change the values as needed...
Michael Eshom
Christian Metal Fans

cellDamage

I've been looking at the smf_members table i have currently, theres a lot of fields! Some of which look to be generated when someone signs up, such as registration date and the like.. do i not need these?   :-\

[Unknown]

Actually, the above isn't good enough.  Bare minimum, you need:

emailAddress
realName
memberName
passwd
passwordSalt

So...

INSERT INTO smf_members
   (emailAddress, realName, memberName, passwd, passwordSalt, dateRegistered)
VALUES ('[email protected]', 'example', 'example', MD5('password'), '', UNIX_TIMESTAMP());

-[Unknown]

cellDamage

thank you! i did figure there were a few missing  ;)

Advertisement: