使用环境:在首页或其他页面进行注册或登录功能、绑定独立域名的页面上登录功能。

一、登录功能

<form class="content" id="loginform" method="post" novalidate="novalidate">
    {dr_form_hidden()}
    <div class="form-group">
        <div class="input-icon">
            <i class="fa fa-user"></i>
            <input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="账号/邮箱/手机" name="data[username]">
        </div>
    </div>
    <div class="form-group">
        <div class="input-icon">
            <i class="fa fa-lock"></i>
            <input class="form-control placeholder-no-fix" type="password" autocomplete="off" placeholder="登录密码" name="data[password]">
        </div>
    </div>
    {if $ci->member_cache['login']['code']}
    <div class="form-group">
        <div class="input-group login-code">
            <div class="input-icon">
                <i class="fa fa-code"></i>
                <input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="验证码" name="code">
            </div>
            <div class="input-group-btn fc-code">
                {dr_code(120, 35)}
            </div>
        </div>
    </div>
    {/if}
    <div class="form-actions">
        <label class="rememberme mt-checkbox mt-checkbox-outline">
            <input type="checkbox" name="remember" value="1"> 记住登录
            <span></span>
        </label>
        <button type="button" onclick="dr_ajax_member('/index.php?s=api&c=sso&m=login', 'loginform');" class="btn green pull-right"> 登录 </button>
    </div>
</form>

二、注册代码

{php extract(dr_get_register_value());}
<p>调试信息:{$debug}</p>
<form action="" class="form-horizontal form" method="post" name="regform" id="regform">
    {$form}
    <div class="form-body">

        {if in_array('username', $register.field)}
        <div class="form-group" id="dr_row_username">
            <label class="col-md-1 control-label">账号</label>
            <div class="col-md-10">
                <input type="text" class="form-control " name="data[username]" id="dr_username">
            </div>
        </div>
        {/if}
        {if in_array('email', $register.field)}
        <div class="form-group " id="dr_row_email">
            <label class="col-md-1 control-label">邮箱</label>
            <div class="col-md-10">
                <input type="text" class="form-control " name="data[email]" id="dr_email">
            </div>
        </div>
        {/if}
        {if in_array('phone', $register.field)}
        <div class="form-group " id="dr_row_phone">
            <label class="col-md-1 control-label">手机号</label>
            <div class="col-md-10">
                <input type="text" class="form-control " name="data[phone]" id="dr_phone">
            </div>
        </div>
        {/if}
        {if in_array('name', $register.field)}
        <div class="form-group " id="dr_row_name">
            <label class="col-md-1 control-label">姓名</label>
            <div class="col-md-10">
                <label><input type="text" class="form-control input-large" name="data[name]" id="dr_name"></label>
            </div>
        </div>
        {/if}
        <div class="form-group " id="dr_row_password">
            <label class="col-md-1 control-label">密码</label>
            <div class="col-md-10">
                <input type="password" class="form-control " name="data[password]" id="dr_password">
            </div>
        </div>
        <div class="form-group " id="dr_row_password2">
            <label class="col-md-1 control-label">确认密码</label>
            <div class="col-md-10">
                <input type="password" class="form-control " name="data[password2]" id="dr_password2">
            </div>
        </div>
{$myfield}
{$diyfield}
{$sysfield}
        {if $register.sms}
        <div class="form-group" id="dr_row_sms">
            <label class="col-md-1 control-label">短信验证</label>
            <div class="col-md-10">
                <div class="input-group input-large">
                    <input class="form-control placeholder-no-fix" type="text" autocomplete="off" id="dr_sms" name="sms">
                    <div class="input-group-btn">
                        <button class="btn blue" onclick="dr_ajax_url('/index.php?s=member&c=api&m=register_code&id='+$('#dr_phone').val()+'&code='+$('#dr_code').val())" type="button">获取手机验证码</button>
                    </div>
                </div>
            </div>
        </div>
        {/if}
        {if $register.sms || $register.code}
        <div class="form-group" id="dr_row_code">
            <label class="col-md-1 control-label">验证码</label>
            <div class="col-md-10">
                <div class="input-group input-large">
                    <input class="form-control placeholder-no-fix" type="text" autocomplete="off" id="dr_code" name="code">
                    <div class="input-group-btn fc-code">
                        {dr_code(120, 35)}
                    </div>
                </div>
            </div>
        </div>
        {/if}
        <div class="form-group" style="margin-top:30px">
            <button type="button" onclick="dr_ajax_submit('/index.php?s=api&c=sso&m=register', 'regform', '2000')" class=" btn red btn-block"> 立即注册 </button>
        </div>

        <div class="form-group" style="margin-top:30px">
            <label class="mt-checkbox mt-checkbox-outline" style="margin-left:20px;">
                <input type="checkbox" name="is_protocol" value="1" checked> 我已阅读并同意
                <span></span>
            </label>
            <label>
                <a href="[removed]dr_show_protocol();">《用户注册协议》</a>
            </label>
        </div>
    </div>
</form>

如果指定用户组注册时可以改变函数参数:

{php extract(dr_get_register_value(222))} 222表示用户组的id号

三、如果注册其他用户组怎么办改?

只需要改变一下注册按钮参数

<button type="button" onclick="dr_ajax_submit('/index.php?s=api&c=sso&m=register&groupid=88888888', 'regform', '2000')" class=" btn red btn-block"> 立即注册 </button>
8888888就改成你要注册的用户组id号

四、登录或注册后跳转到指定url写法

只需要在提交的函数加一个back参数:

&back={urlencode('http://www.baidu.com')}

登录示例:

<button type="button" onclick="dr_ajax_member('/index.php?s=api&c=sso&m=login&back={urlencode('http://www.baidu.com')}', 'loginform');" class="btn green pull-right"> 登录 </button>

                           在我们使用迅睿CMS时候出现外部页面 登录/注册问题,以上就是XunRuiCMS外部页面 登录/注册解决的教程

点赞(0) 收藏(0)

评论列表

立即
投稿

微信客服

微信扫一扫

返回
顶部