To import data to the ucenter and forum, or to other cms users, you only need to operate on the two ucenter tables. uc_members and uc_memberfields do not have many updated fields, in general, it is very easy to import data from its system to the ucenter for member stop.
Php Tutorial: Import member data to ucenter code
/*
The member table structure we want to use
Create table if not exists 'net _ 111cnnet '(
'Id' int (11) not null auto_increment,
'Username' varchar (32) default null,
'Add _ time' int (11) default null,
'Email 'varchar (50) default null,
'Password' varchar (50) default null,
'Last _ login' int (4) default null
Primary key ('id ')
) Engine = myisam default charset = utf8 auto_increment = 1;
Member table
*/
$ Host = 'localhost ';
$ Db = 'abc ';
$ User = 'root ';
$ Password = 'root ';
// Database tutorial connection configuration, because my ucenter table is in the same database as the current member table, it is just a connection.
Try {
$ Conn = mysql tutorial _ connect ($ host, $ user, $ password );
Mysql_select_db ($ db, $ conn );
} Catch (dbexception $ e ){
Exit ('database connect fail! '); // Database Error Handling Location
}
$ SQL = "select * from net_111cnnet"; // find all member data to be imported to ucenter
$ Query = mysql_query ($ SQL, $ conn );
While ($ rs = mysql_fetch_array ($ query ))
{
$ Uc_ SQL = "select * from uc_members where username = '". $ rs ['username']. "'";
$ Data = mysql_query ($ uc_ SQL );
If ($ data)
{
;
}
Else
{
$ Salt = substr (uniqid (rand (),-6 );
$ Password = md5 ($ rs ['Password']. $ salt); // generate a User Login password according to ucenter rules
Mysql_query ("insert into uc_members set uid = '". $ rs ['id']. "', username = '". $ rs ['username']. "', password =' $ password', email = '". $ rs ['email ']. "', lastlogintime = '". $ rs ['last _ login']. "', regdate = '". $ rs ['add _ time']. "', salt =" $ salt ""); // insert data to the uc_members table.
Mysql_query ("insert into uc_memberfields set uid = '". $ rs ['id']. "'"); // update the uc_memberfields table.
}
}
Exit ('all users have been imported to ucenter ');
/*
Summary:
To import data to the ucenter and forum, or to other cms users, you only need to operate on the two ucenter tables. uc_members and uc_memberfields do not have many updated fields, in general, it is very easy to import data from its system to the ucenter for member stop.
This article is originally reproduced on www.bkjia.com. Please respect others' labor achievements and indicate the source.
*/