咨询,就免费赠送小米移动电源,咨询热线:18030402705当前位置: 主页 > 建站知识 > 二次开发 > DISCUZ二次开发 >

Discuz! X3.1 判断会员登录状态及外部调用注册登录

作者/整理:07fly 来源:δ֪ 2015-11-24 Tag:

在帝国的html里加入html代码


复制代码代码如下:
<div class="login">
<form id="login-form" action="/login.shtml" method="post"> <div class="row username">
<label for="LoginForm_username" class="required">用户名 <span class="required">*</span></label> <input size="30" class="px" autocomplete="off" tabindex="1" name="LoginForm[username]" id="LoginForm_username" type="text" /> <a title="" href="http://bbs.jb51.net/member.php?mod=register&referer=http://ka.18183.com/">立即注册</a><div class="clear"> </div>
<div class="errorMessage" id="LoginForm_username_em_" style="display:none"></div> </div>
<div class="row userpwd">
<label for="LoginForm_password" class="required">密码 <span class="required">*</span></label> <input size="30" class="px" autocomplete="off" tabindex="2" name="LoginForm[password]" id="LoginForm_password" type="password" /> <a title="" href="http://www.jb51.net/cms/#">找回密码</a>
<div class="clear"> </div>
<div class="errorMessage" id="LoginForm_password_em_" style="display:none"></div> </div>

<div class="row rememberMe">
<input id="ytLoginForm_rememberMe" type="hidden" value="http://www.jb51.net/cms/0" name="LoginForm[rememberMe]" /><input tabindex="4" name="LoginForm[rememberMe]" id="LoginForm_rememberMe" value="http://www.jb51.net/cms/1" type="checkbox" /> <label for="LoginForm_rememberMe">自动登录</label> <div class="errorMessage" id="LoginForm_rememberMe_em_" style="display:none"></div><div class="clear"> </div>
</div>

<div class="row login_btn">
<input class="pn pnc" type="submit" name="yt0" value="http://www.jb51.net/cms/登录" /> <a title="" href="http://bbs.jb51.net/connect.php?mod=login&op=init&referer=http://www.jb51.net/" class="qq">QQ登录</a><div class="clear"> </div>
</div>

</form>
</div>
<div class="info" style="display:none">

<div class="info_img"></div>
<div class="info_info">
<div class="info_info_name">dfsafd23eedsafd@qq.com</div>
<div class="info_info_links">
<a target="_blank" href="http://www.jb51.net/cms//home.php?mod=spacecp&ac=credit">我的积分</a>|<a href="http://www.jb51.net/boom.shtml" target="_blank" >我的礼包</a>

<a target="_blank" href="http://www.jb51.net/cms//home.php?mod=space&do=notice&view=system">提醒</a>|<a href="http://www.jb51.net/logout.shtml">退出</a>
</div>
</div>
<div class="clear"> </div>
<div class="info_txt">

</div>
</div>

在discuz下写个zxf_userinfo.php放在discuz根目录就可以了


复制代码代码如下:
<?php
require './source/class/class_core.php';
$discuz = & discuz_core::instance();
$discuz->init_cron = false;
$discuz->init_session = false;
$discuz->init();
//echo $_G['uid'];
echo $_G['uid'].'|'.$_G['username'].'|0';
?>

在页面下方利用ajax获取该页面的值,不多说了,直接看代码吧


复制代码代码如下:
<script>
$(document).ready(function(){
var bbsurl='http://bbs.jb51.net/';
var url=bbsurl+'/zxf_userinfo.php';
var uid,uname,uscore;
$.ajax({type: "GET",url: url,data: "?"+Math.random(),dataType: "text",success: function(a){
for (var c = a.split("|"), d = 0; d < c.length;){uid = c[d++],uname= c[d++],uscore= c[d++];}
if(uid){
$('.login').remove();
$('.info').show();
$('.info_info_name').html(uname);
$('.info_img').html('<a href="http://www.jb51.net/cms/#"><img src='http://www.jb51.net/cms/+bbsurl+'/uc_server/avatar.php?uid='+uid+'&size=small /></a>');
}
else{
$('.info').remove();
$('.login').show();
}
}});


});
</script>

本文零起飞网络为您整理编辑,版权归原作者所有,转载请注明原文来源出处。
本文章链接:http://www.07fly.com/Devel/discuz/455.html
07FLY专业做网站,网站建设,网站优化,主机托管,网站推广一条龙服务,让您省心到底