K9自带的ajax登陆/注册标签调用步骤以下:
- 加载涉及登陆/注册用到的JS和CSS,放在<head>中
<script type="text/javascript" charset="UTF-8" src="{DIR}user/js/jquery.js"></script> <script type="text/javascript" charset="UTF-8" src="{DIR}user/js/system.js"></script> <link media="screen" type="text/css" href="{DIR.T}css/system.css" rel="stylesheet">
- 链接式登陆/注册标签:
{#if($u->info['islogin'])} 您好,<strong><?=$u->info['username']?></strong> <a href="javascript:;" onClick="$.kc_ajax({URL:'{DIR}user/manage.php',CMD:'logout'})" title="退出登录">退出</a> {? $userid=$u->info['userid'] ?} {@count_pm.count table='%s_pm' where="userid=$userid and islook=0"} <a href="{DIR}?user-pm" title="短信息">站内信{?=empty($count_pm)?'':'(<em>'.$count_pm.'</em>)'?}</a> {#else} <a href="javascript:;" onclick="$.kc_ajax({URL:'{DIR}user/manage.php',CMD:'login',FORM:'login'});return false;">登陆</a> | <a href="javascript:;" onclick="$.kc_ajax({URL:'{DIR}user/manage.php',CMD:'register',FORM:'login'});return false;">注册</a> {#endif}
- 按钮式登陆/注册标签:
{#if($u->info['islogin'])} 您好,<strong><?=$u->info['username']?></strong> <a href="javascript:;" onClick="$.kc_ajax({URL:'{DIR}user/manage.php',CMD:'logout'})" title="退出登录">退出</a> {? $userid=$u->info['userid'] ?} {@count_pm.count table='%s_pm' where="userid=$userid and islook=0"} <a href="{DIR}?user-pm" title="短信息">站内信{?=empty($count_pm)?'':'(<em>'.$count_pm.'</em>)'?}</a> {#else} <form action="" method="post" id="login"> <label>用户名:</label> <input type="text" id="username" name="username" class="w80" size="5" maxlength="12"/> <label>密码:</label> <input type="password" id="userpass" name="userpass" class="w80" size="5" maxlength="30"/> <input type="submit" class="submit_login" value="登录"onClick="$.kc_ajax({URL:'{DIR}user/manage.php',CMD:'login',FORM:'login'});return false;" id="input"/> <input type="submit" class="submit_login" value="注册"onClick="$.kc_ajax({URL:'{DIR}user/manage.php',CMD:'register',FORM:'login'});return false;" id="input"/> </form> {#endif}
转载请注明出处:唯众网络