php將會員數(shù)據(jù)導(dǎo)入到ucenter的代碼
更新時間:2010年07月18日 00:06:19 作者:
php下把會員數(shù)據(jù)導(dǎo)入到ucenter代碼,需要的朋友可以參考下。
我們要用的會員表結(jié)構(gòu)
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';
//數(shù)據(jù)庫教程連接配置,由于我的ucenter表與現(xiàn)在的會員表在同一個數(shù)據(jù)庫所以就一次連接就行了。
try {
$conn = mysql教程_connect($host,$user,$password);
mysql_select_db($db,$conn);
} catch (dbexception $e) {
exit('database connect fail!');// 數(shù)據(jù)庫出錯處理處
}
$sql ="select * from net_111cnnet "; //查出要導(dǎo)入到ucenter所有會員數(shù)據(jù)
$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規(guī)則生成用戶登陸密碼
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'"); //把數(shù)據(jù)插入到uc_members表
mysql_query("insert into uc_memberfields set uid='".$rs['id']."'");//更新uc_memberfields表。
}
}
exit('所有用戶己導(dǎo)入到ucenter');
總結(jié):
導(dǎo)入數(shù)據(jù)到ucenter與論壇,或其它 cms用戶同小只要操作ucenter的兩張表就行了,uc_members,uc_memberfields哦,涉及到更新的字段也不多,所以總體來講把它系統(tǒng)的數(shù)據(jù)導(dǎo)入到ucenter進行會員同止步是很簡單的。
復(fù)制代碼 代碼如下:
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 ;
核心代碼:
復(fù)制代碼 代碼如下:
$host ='localhost';
$db ='abc';
$user='root';
$password ='root';
//數(shù)據(jù)庫教程連接配置,由于我的ucenter表與現(xiàn)在的會員表在同一個數(shù)據(jù)庫所以就一次連接就行了。
try {
$conn = mysql教程_connect($host,$user,$password);
mysql_select_db($db,$conn);
} catch (dbexception $e) {
exit('database connect fail!');// 數(shù)據(jù)庫出錯處理處
}
$sql ="select * from net_111cnnet "; //查出要導(dǎo)入到ucenter所有會員數(shù)據(jù)
$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規(guī)則生成用戶登陸密碼
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'"); //把數(shù)據(jù)插入到uc_members表
mysql_query("insert into uc_memberfields set uid='".$rs['id']."'");//更新uc_memberfields表。
}
}
exit('所有用戶己導(dǎo)入到ucenter');
總結(jié):
導(dǎo)入數(shù)據(jù)到ucenter與論壇,或其它 cms用戶同小只要操作ucenter的兩張表就行了,uc_members,uc_memberfields哦,涉及到更新的字段也不多,所以總體來講把它系統(tǒng)的數(shù)據(jù)導(dǎo)入到ucenter進行會員同止步是很簡單的。
相關(guān)文章
PHP函數(shù)篇之掌握ord()與chr()函數(shù)應(yīng)用
ord()函數(shù)把字符轉(zhuǎn)換為十進制數(shù)字,chr()函數(shù)把十進制數(shù)字轉(zhuǎn)化為字符,在二進制,八進制,十進制與十六進制之間充當(dāng)橋梁的作用2011-12-12PHP+Mysql+jQuery實現(xiàn)發(fā)布微博程序 jQuery篇
我們在QQ個人中心或者新浪微博等網(wǎng)站上可以看到一個發(fā)表話題的應(yīng)用2011-10-10php基于session實現(xiàn)數(shù)據(jù)庫交互的類實例
這篇文章主要介紹了php基于session實現(xiàn)數(shù)據(jù)庫交互的類,實例分析了php結(jié)合session操作數(shù)據(jù)庫的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-08-08深思 PHP 數(shù)組遍歷的差異(array_diff 的實現(xiàn))
深思 PHP 數(shù)組遍歷的差異(array_diff 的實現(xiàn))...2006-06-06php時區(qū)轉(zhuǎn)換轉(zhuǎn)換函數(shù)
godaddy主機在國外。把站點建站國外,顯示時間時可能需要時區(qū)轉(zhuǎn)換,下面是個方便的工具函數(shù),用于時區(qū)轉(zhuǎn)換2014-01-01