Home >Backend Development >PHP Tutorial >php将会员数据导入到ucenter的代码_PHP

php将会员数据导入到ucenter的代码_PHP

WBOY
WBOYOriginal
2016-06-01 12:17:58908browse

我们要用的会员表结构
复制代码 代码如下:
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 ;

核心代码:
复制代码 代码如下:
$host ='localhost';
$db ='abc';
$user='root';
$password ='root';
//数据库教程连接配置,由于我的ucenter表与现在的会员表在同一个数据库所以就一次连接就行了。

try {
$conn = mysql教程_connect($host,$user,$password);
mysql_select_db($db,$conn);
} catch (dbexception $e) {
exit('database connect fail!');// 数据库出错处理处
}

$sql ="select * from net_111cnnet "; //查出要导入到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);//按照ucenter规则生成用户登陆密码

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'"); //把数据插入到uc_members表
mysql_query("insert into uc_memberfields set uid='".$rs['id']."'");//更新uc_memberfields表。
}
}
exit('所有用户己导入到ucenter');


总结:
导入数据到ucenter与论坛,或其它 cms用户同小只要操作ucenter的两张表就行了,uc_members,uc_memberfields哦,涉及到更新的字段也不多,所以总体来讲把它系统的数据导入到ucenter进行会员同止步是很简单的。

Statement:
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