织梦dedecms在启用二级域名后 由于DEDEAjax不能跨域所以使用ajax返回登录数据不能成功,对ajax跨域实在是找不到比较好的方法所以暂时采用以下方法替代:
第一步,在member文件夹处建立一个php文件,名字为“ajax_index_loginsta_s.php”。
第二步,给这个文件中填写的代码为:
<?php require_once(dirname(__FILE__)."/config.php"); AjaxHead(); if($myurl == '') { echo "document.write('<div id=_userlogin>');"; echo "document.write('<form name=userlogin action=".$GLOBALS['cfg_cmsurl']."/member/index_do.php method=POST>');"; echo "document.write('<input type=hidden name=fmdo value=login />');"; echo "document.write('<input type=hidden name=dopost value=login />');"; echo "document.write('<input type=hidden name=keeptime value=604800 />');"; echo "document.write('<div class=s1>用户名</div><div class=s2><input type=text name=userid /></div> ');"; echo "document.write('<div class=s1>密码</div><div class=s2><input name=pwd type=password /></div> ');"; echo "document.write('<div class=s1>验证码</div><div class=s2 id=s2><input name=vdcode type=text maxlength=4 /></div>');"; echo "document.write('<div class=simg><img src=".$GLOBALS['cfg_cmsurl']."/include/vdimgck.php width=50 height=20 /></div><div class=s3><input type=submit value=登录 /> </div>');"; echo "document.write('<div class=s1><a href=".$GLOBALS['cfg_cmsurl']."/member/resetpassword.php target=_blank>忘记密码?</a> <a href=".$GLOBALS['cfg_cmsurl']."/member/index_do.php?fmdo=user&dopost=regnew target=_blank><font color=#FF0000>免费注册</font></a></div>');"; echo "document.write('</form></div>');"; exit(''); } $uid = $cfg_ml->M_LoginID; $face = $cfg_ml->fields['face'] == '' ? $GLOBALS['cfg_memberurl'].'/images/nopic.gif' : $cfg_ml->fields['face']; echo "document.write('<div class=s5><b>".$cfg_ml->M_UserName."</b> 欢迎登陆XXXXXXXX!<a href=".$cfg_memberurl."/index.php>会员中心</a> | <a href=".$cfg_memberurl."/edit_fullinfo.php>帐户</a> | <a href=".$myurl.">我的Blog</a> | <a href=".$cfg_memberurl."/index_do.php?fmdo=login&dopost=exit><font color=#FF0000>退出登陆</font></a></div>');"; ?> |
适当的自己修改吧,我这个主要用在顶部登陆,所以都是横着放的。
第三步,把所有需要添加登陆的页面中增加一行代码:
<script language="javascript" type="text/javascript" src="http://你的域名/member/ajax_index_loginsta_s.php"></script> |
评论