Php imports member data to ucenter code

Source: Internet
Author: User

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.
*/


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.