discuz ucenter的用户注册接口函数详解

摘要:discuz ucenter的用户注册接口函数...

作者:LoveCode标签:discuz,ucenter,用户注册,接口,函数

discuz ucenter 用户注册详解: 


 HTML部分:

<form id="registerForm" method="post" class="form-horizontal" role="form" action="/validator.php">
        <div class="form-group  has-feedback">
            <label class="col-sm-4 control-label">用户名</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" name="username" placeholder="输入3-15个字符"/>
            </div>
        </div>

        <div class="form-group  has-feedback">
            <label class="col-sm-4 control-label">邮箱</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" name="email" placeholder="格式:xxx@xxx.xxx"/>
            </div>
        </div>

        <div class="form-group  has-feedback">
            <label class="col-sm-4 control-label">密码</label>
            <div class="col-sm-5">
                <input type="password" class="form-control" name="password" placeholder="输入6-18个字符"/>
            </div>
        </div>

        <div class="form-group  has-feedback">
            <label class="col-sm-4 control-label">确认密码</label>
            <div class="col-sm-5">
                <input type="password" class="form-control" name="confirmPassword" placeholder="输入相同密码"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-lg-offset-3">
                <button type="submit" class="btn btn-danger">确认注册</button>
                <button type="button" class="btn btn-warning" id="resetBtn">重新填写</button>
                <button type="button" class="btn btn-info" id="resetBtn">关闭窗口</button>
            </div>
        </div>
        <input type="hidden" name="FUCKYOU" value="INTHERAIN" />
    </form>


后端部分:

if($_POST['FUCKYOU'] && $_POST['FUCKYOU']=='INTHERAIN')
{
    include_once './config/config_ucenter.php';
    include_once './uc_client/client.php';

    $username = post_check($_POST['username']);
    $email = post_check($_POST['email']);
    $password = post_check($_POST['password']);

    $uid = uc_user_register($username, $password, $email);
    if($uid <= 0) {
        if($uid == -1) {
            echo '用户名不合法';
        } elseif($uid == -2) {
            echo '包含要允许注册的词语';
        } elseif($uid == -3) {
            echo '用户名已经存在';
        } elseif($uid == -4) {
            echo 'Email 格式有误';
        } elseif($uid == -5) {
            echo 'Email 不允许注册';
        } elseif($uid == -6) {
            echo '该 Email 已经被注册';
        } else {
            echo '未定义';
        }
    } else {
        echo $uid;
        echo '注册成功';
    }
}

function post_check($post) {
    if(!get_magic_quotes_gpc()) {
        $post = addslashes($post);
    }
    $post = str_replace("_", "\_", $post);
    $post = str_replace("%", "\%", $post);
    $post = nl2br($post);
    $post = htmlspecialchars($post);

    return $post;
}


CopyRight © 2017 荒山本的官方网站 粤ICP备16049175号 All Right Service 网站地图(xml) 网站地图(html)