然后 需要显示的地方插入 以下代码
<div id="_userlogin">
<div class="userlogin">
<form name="userlogin" action="{dede:global.cfg_memberurl/}/index_do.php" method="POST">
<input type="hidden" name="fmdo" value="login" />
<input type="hidden" name="dopost" value="login" />
<input type="hidden" name="keeptime" value="604800" />
<div class="fb"><span>用户名:</span>
<input type="text" name="userid" size="20" class="ipt-txt" />
</div>
<div class="fb"><span>密码:</span>
<input type="password" name="pwd" size="20" class="ipt-txt" />
</div>
{dede:php}
if(preg_match("#2#", $safe_gdopen))
{
echo ‘
<div class="fb"><span>验证码:</span>
<input type="text" name="vdcode" size="8" class="ipt-txt" />
<img id="vdimgck" align="absmiddle"
onClick=""http://blog.51cto.com/viewpic.php?refimg=" + this.src="http://blog.51cto.com/viewpic.php?refimg=" + this.src+\‘?\‘"
style="cursor:pointer;margin-left:0px;text-transform:uppercase;"
alt="看不清?点击更换"
src="‘.$cfg_cmspath.‘/include/vdimgck.php"/></div>
‘;
}
{/dede:php}
<div class="submit">
<button type="submit" class="btn-1">登录</button>
<a
href="{dede:global.cfg_memberurl/}/index_do.php?fmdo=user&dopost=regnew"
>注册帐号</a> <a
href="{dede:global.cfg_memberurl/}/resetpassword.php">忘记密码?</a>
</div>
</form>
</div>
</div>
<!-- /userlogin -->
<script language="javascript" type="text/javascript">CheckLogin();</script>
登录后的显示在 ajax_loginsta.php里修改。
特别注意如果是dede5.7则js调用应该是修改为:
<script language="javascript" type="text/javascript" src="{dede:global.cfg_cmsurl/}/include/js/dedeajax2.js"></script>
<script language="javascript" type="text/javascript">
<!--
function CheckLogin(){
var taget_obj = document.getElementById(‘_userlogin‘);
myajax = new DedeAjax(taget_obj,false,false,‘‘,‘‘,‘‘);
myajax.SendGet2("{dede:global.cfg_cmspath/}/member/ajax_loginsta6.php");
DedeXHTTP = null;
}
-->
</script>
如果顶部不想显示那么多内容,则可以精简为以下内容:
require_once(dirname(__FILE__)."/config.php");
AjaxHead();
if($myurl == ‘‘) exit(‘‘);
$uid = $cfg_ml->M_LoginID;
!$cfg_ml->fields[‘face‘] && $face = ($cfg_ml->fields[‘sex‘] == ‘女‘)? ‘dfgirl‘ : ‘dfboy‘;
$facepic = empty($face)? $cfg_ml->fields[‘face‘] : $GLOBALS[‘cfg_memberurl‘].‘/templets/images/‘.$face.‘.png‘;
?>
你好:<strong><?php echo $cfg_ml->M_UserName; ?></strong> <a href="<?php echo $cfg_memberurl; ?>/index.php">会员中心</a> <a href="<?php echo $cfg_memberurl; ?>/index_do.php?fmdo=login&dopost=exit">退出</a>
<!-- /userinfo -->