Home > Backend Development > PHP Tutorial > PHP imports member data into ucenter code_PHP tutorial

PHP imports member data into ucenter code_PHP tutorial

WBOY
Release: 2016-07-20 11:08:19
Original
1062 people have browsed it

To import data to ucenter and forums, or other cms users, you only need to operate the two tables of ucenter, uc_members and uc_memberfields. There are not many fields involved in updating, so generally speaking, import the data of the system into ucenter. Member synchronization is very simple.

PHP tutorial to import member data into 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. Since my ucenter table and the current membership table are in the same database, just one connection is enough.

try {
$conn = mysql tutorial_connect($host,$user,$password);
mysql_select_db($db,$conn);
} catch ( dbexception $e) {
exit('database connect fail!');//Database error handling
}

$sql ="select * from net_111cnnet "; //Find out what to import All member data 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);//Follow ucenter Rules generate user login password

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 into uc_members table
mysql_query("insert into uc_memberfields set uid='".$rs['id']."'"); //Update uc_memberfields table.
}
}
exit('All users have been imported to ucenter');

/*
Summary:
Import data to ucenter and forum, or Other cms users only need to operate the two tables of ucenter, uc_members and uc_memberfields. There are not many fields involved in updating, so generally speaking, it is very simple to import the data of its system into ucenter for member synchronization.
This article was originally published on www.bkjia.com. Friends who reprinted it please respect the work of others and indicate the source.
*/


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444897.htmlTechArticleImport data to ucenter and forum, or other cms users only need to operate the two tables of ucenter, uc_members , uc_memberfields, there are not many fields involved in updating, so overall...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template