怎么用AJAX来判断dedecms用户是否登录呢

JS代码:
Copy code
<script language="javascript" src="{dede:global name='cfg_cmspath'/}/include/dedeajax2.js"></script>
<script language="javascript">
function CheckUser(){
var taget_obj = document.getElementById('_userboxform');
myajax = new DedeAjax(taget_obj,false,false,"","","");
myajax.SendGet2("{dede:global name="cfg_memberurl"/}/userboxsta.php");
DedeXHTTP = null;
}
</script>
然后我们修改下内容页部分的代码
找到:
<div class="userbox">
<dl>
<dd class="mtop">
<strong>用户名:</strong><input name="username" class="username" type="text" maxlength="20" />
<strong>密码:</strong><input name="pwd" class="password" type="password" maxlength="20" />
</dd>
将其修改为
<div class="userbox">
<dl>
<dd class="mtop"> <span id="_userboxform">
<strong>用户名:</strong><input name="username" class="username" type="text" maxlength="20" />
<strong>密码:</strong><input name="pwd" class="password" type="password" maxlength="20" /> </span> 
</dd>
即加上<span id="_userboxform">,用于判断用户是否已经登录。
下面我们来写一�php文件,用户传送数据,将其保存为/member/userboxsta.php,其代码如下:
Copy code
<?php 
header("Pragma:no-cache\r\n");
header("Cache-Control:no-cache\r\n");
header("Expires:0\r\n");
header("Content-Type: text/html; charset=gb2312");
//系统设置为维护状态可访问
$cfg_IsCanView = true;
require_once(dirname(__FILE__)."/../include/inc_memberlogin.php");
$cfg_ml = new MemberLogin(); 
if(empty($cfg_ml->M_ID)){ echo ""; exit(); }
$uid = $cfg_ml->M_LoginID;
?>
<strong>欢迎您</strong>[<?php echo $cfg_ml->M_UserName?>],现在你可以直接发布留言

转载于:https://www.cnblogs.com/2881064178dinfeng/p/6233870.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值