php將會(huì)員數(shù)據(jù)導(dǎo)入到ucenter的代碼
更新時(shí)間:2010年07月18日 00:06:19 作者:
php下把會(huì)員數(shù)據(jù)導(dǎo)入到ucenter代碼,需要的朋友可以參考下。
我們要用的會(huì)員表結(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)在的會(huì)員表在同一個(gè)數(shù)據(jù)庫所以就一次連接就行了。
try {
$conn = mysql教程_connect($host,$user,$password);
mysql_select_db($db,$conn);
} catch (dbexception $e) {
exit('database connect fail!');// 數(shù)據(jù)庫出錯(cuò)處理處
}
$sql ="select * from net_111cnnet "; //查出要導(dǎo)入到ucenter所有會(huì)員數(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進(jìn)行會(huì)員同止步是很簡(jiǎn)單的。
復(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)在的會(huì)員表在同一個(gè)數(shù)據(jù)庫所以就一次連接就行了。
try {
$conn = mysql教程_connect($host,$user,$password);
mysql_select_db($db,$conn);
} catch (dbexception $e) {
exit('database connect fail!');// 數(shù)據(jù)庫出錯(cuò)處理處
}
$sql ="select * from net_111cnnet "; //查出要導(dǎo)入到ucenter所有會(huì)員數(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進(jìn)行會(huì)員同止步是很簡(jiǎn)單的。
您可能感興趣的文章:
- thinkPHP實(shí)現(xiàn)簽到功能的方法
- php+mysql+jquery實(shí)現(xiàn)日歷簽到功能
- PHP+MYSQL會(huì)員系統(tǒng)的開發(fā)實(shí)例教程
- PHP+MYSQL會(huì)員系統(tǒng)的登陸即權(quán)限判斷實(shí)現(xiàn)代碼
- PHP會(huì)員找回密碼功能的簡(jiǎn)單實(shí)現(xiàn)
- PHP實(shí)現(xiàn)生成唯一會(huì)員卡號(hào)
- Php連接及讀取和寫入mysql數(shù)據(jù)庫的常用代碼
- php讀取數(shù)據(jù)庫信息的幾種方法
- php mysql數(shù)據(jù)庫操作類
- php實(shí)現(xiàn)簽到功能的方法實(shí)例分析
相關(guān)文章
PHP函數(shù)篇之掌握ord()與chr()函數(shù)應(yīng)用
ord()函數(shù)把字符轉(zhuǎn)換為十進(jìn)制數(shù)字,chr()函數(shù)把十進(jìn)制數(shù)字轉(zhuǎn)化為字符,在二進(jìn)制,八進(jìn)制,十進(jìn)制與十六進(jìn)制之間充當(dāng)橋梁的作用2011-12-12PHP+Mysql+jQuery實(shí)現(xiàn)發(fā)布微博程序 jQuery篇
我們?cè)赒Q個(gè)人中心或者新浪微博等網(wǎng)站上可以看到一個(gè)發(fā)表話題的應(yīng)用2011-10-10php基于session實(shí)現(xiàn)數(shù)據(jù)庫交互的類實(shí)例
這篇文章主要介紹了php基于session實(shí)現(xiàn)數(shù)據(jù)庫交互的類,實(shí)例分析了php結(jié)合session操作數(shù)據(jù)庫的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08深思 PHP 數(shù)組遍歷的差異(array_diff 的實(shí)現(xiàn))
深思 PHP 數(shù)組遍歷的差異(array_diff 的實(shí)現(xiàn))...2006-06-06php時(shí)區(qū)轉(zhuǎn)換轉(zhuǎn)換函數(shù)
godaddy主機(jī)在國(guó)外。把站點(diǎn)建站國(guó)外,顯示時(shí)間時(shí)可能需要時(shí)區(qū)轉(zhuǎn)換,下面是個(gè)方便的工具函數(shù),用于時(shí)區(qū)轉(zhuǎn)換2014-01-01