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.
<?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...
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? :-\
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]
thank you! i did figure there were a few missing ;)