Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php jquery ui对话框表单验证 Jquery UI对话框窗体:_Php_Javascript_Jquery_Mysql_Jquery Ui - Fatal编程技术网

Php jquery ui对话框表单验证 Jquery UI对话框窗体:

Php jquery ui对话框表单验证 Jquery UI对话框窗体:,php,javascript,jquery,mysql,jquery-ui,Php,Javascript,Jquery,Mysql,Jquery Ui,我必须创建一个新网站的注册 使用: jquery用户界面 php mysql Html5 问题是: 无法检查用户或电子邮件是否存在 check_exist函数返回notexist的值,它总是未定义 当删除if的notexist(bValid&¬exist)时,它工作正常 如何检查key up上是否存在电子邮件 如果出现任何错误,如何禁用注册按钮 ajax.php文件源: js文件源: $(函数(){ $(“#性别”).buttonset(); var info=$('#notfi inf

我必须创建一个新网站的注册

使用:
  • jquery用户界面
  • php
  • mysql
  • Html5
  • 问题是:
  • 无法检查用户或电子邮件是否存在
  • check_exist函数返回notexist的值,它总是未定义
  • 当删除if的notexist(bValid&¬exist)时,它工作正常
  • 如何检查key up上是否存在电子邮件
  • 如果出现任何错误,如何禁用注册按钮

  • ajax.php文件源: js文件源:
    $(函数(){
    $(“#性别”).buttonset();
    var info=$('#notfi info').hide();
    $('#notfi error').hide();
    变量名称=$(“#名称”)、电子邮件=$(“#电子邮件”)、密码=$(“#密码”)、用户名=$(“#用户名”)、电话=$(“#电话”)、性别=$(“#性别输入[姓名=性别]”、国籍=$(“#国籍”),所有字段=$([])。添加(姓名)。添加(电子邮件)。添加(密码)。添加(用户名)。添加(电话)。添加(密码)。添加(国籍),提示=(“#验证”);
    函数getradio(r){
    if(r.filter(':checked')){
    if(r.filter(':checked').val()==“男性”| | r.filter(':checked').val()==“女性”){
    返回r.filter(':checked');
    }
    }否则{
    返回false;
    }
    }
    函数更新(t){
    text(t).addClass(“ui状态突出显示”);
    setTimeout(函数(){
    removeClass(“ui状态突出显示”,1500);
    }, 500);
    }
    函数校验长度(o、n、最小值、最大值){
    如果(o.val().length>max | | o.val().lengthrequire_once '../global.php';
    if ($_GET['do'] == "register") {
    if (isset($_POST['name'])) {
        $name = strip_tags($_POST['name']);
        $pass = strip_tags($_POST['password']);
        $ins = mysql_insert('users', array('u_name' => $name, 'password' => $pass));
    
        if ($ins) {
            $u_id = mysql_insert_id();
            $username = strip_tags($_POST['username']);
            $telephone = strip_tags($_POST['telephone']);
            $gender = strip_tags($_POST['gender']);
            $nationality = strip_tags($_POST['nationality']);
            $email = strip_tags($_POST['email']);
    
            $ins2 = mysql_insert('patient_info', 
            array(
            'u_no' => $u_id, 
            'name' => $username, 
            'gender' => $gender,
            'nationality' => $nationality,
            'tel' => $telephone,
            'email' => $email
            ));
            if ($ins2) {
                echo "Welcome  you can login now :)";
            }
        } 
    }
    }
    
    if ($_GET['do'] == "userexist") {
    $username = $_POST['username'];
    $result = mysql_query("select * from users where u_name ='" . $username . "'");
    
    $row = mysql_fetch_row($result);
    if ($row > 0) {
        echo 1;
    }else{
        echo 0;
    }
    }
    if ($_GET['do'] == "mailexist") {
    $email = $_POST['email'];
    $result = mysql_query("select * from patient_info where email ='" . $email . "'");
    
    $row = mysql_fetch_row($result);
    if ($row > 0) {
        echo 1;
    }else{
        echo 0;
    }
    }
    
    $(function() {
    $("#gender").buttonset();
    var info = $('#notfi-info').hide();
    $('#notfi-error').hide();
    var name = $("#name"), email = $("#email"), password = $("#password"), username = $("#username"), telephone = $("#telephone"), gender = $('#gender input[name=gender]'), nationality = $("#nationality"), allFields = $([]).add(name).add(email).add(password).add(username).add(telephone).add(password).add(nationality), tips = $("#validateTips");
    
    function getradio(r) {
        if (r.filter(':checked')) {
            if (r.filter(':checked').val() == "male" || r.filter(':checked').val() == "female") {
                return r.filter(':checked');
            }
        } else {
            return false;
        }
    }
    
    function updateTips(t) {
        tips.text(t).addClass("ui-state-highlight");
        setTimeout(function() {
            tips.removeClass("ui-state-highlight", 1500);
        }, 500);
    }
    
    function checkLength(o, n, min, max) {
        if (o.val().length > max || o.val().length < min) {
            o.addClass("ui-state-error");
            updateTips("Length of " + n + " must be between " + min + " and " + max + ".");
            return false;
        } else {
            return true;
        }
    }
    
    function checkRegexp(o, regexp, n) {
        if (!( regexp.test(o.val()) )) {
            o.addClass("ui-state-error");
            updateTips(n);
            return false;
        } else {
            return true;
        }
    }
    
    function check_exist(x, y, z, k) {
        jQuery.ajax({
            type : "POST",
            url : "inc/ajax.php?do=" + z,
            data : y + '=' + x.val(),
            cache : false,
            success : function(response) {
                if (response == "1") {
                    x.addClass("ui-state-error");
                    updateTips(k);
                    return false;
                }
                if (response == "0") {
                    return true;
                }
            }
        });
    }
    
    function subregform(form) {
        jQuery.ajax({
            type : form.attr("method"),
            url : form.attr("action"),
            data : form.serialize(),
            success : function(msg) {
                info.find(".info").text(msg);
                info.toggle();
                $(this).dialog("close");
            },
            error : function() {
                alert("failure");
            }
        });
    }
    
    
    $("#dialog-form").dialog({
        autoOpen : false,
        height : 450,
        width : 400,
        modal : true,
        buttons : {
            "Create an account" : function() {
                var bValid = true;
                allFields.removeClass("ui-state-error");
                bValid = bValid && checkLength(name, "login name", 3, 16);
    
                bValid = bValid && checkLength(email, "Email", 6, 80);
                bValid = bValid && checkLength(password, "Password", 5, 16);
                bValid = bValid && checkLength(username, "Username", 5, 16);
                bValid = bValid && checkLength(telephone, "Telephone", 7, 13);
                // bValid = bValid && checkLength(getradio, "Gender", 4, 5);
                bValid = bValid && checkLength(nationality, "Nationality", 3, 25);
    
                bValid = bValid && checkRegexp(telephone, /^[0-9]([0-9])+$/i, "Telephone may consist of 0-9 only.");
                // bValid = bValid && checkRegexp(name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter.");
                // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
                bValid = bValid && checkRegexp(email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com");
                // bValid = bValid && checkRegexp(password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9");
    
                var notexist = true;
    
                notexist = notexist && check_exist(name, 'username', 'userexist', 'Login Name Already Exist!');
                notexist = notexist && check_exist(email, 'email', 'mailexist', 'E-Mail Already Exist!');
                if (bValid && notexist) {
                    var form = $('#dialog-form form');
                    subregform(form);
    
                    // $("#users tbody").append("<tr>" + "<td>" + name.val() + "</td>" + "<td>" + email.val() + "</td>" + "<td>" + password.val() + "</td>" + "<td>" + username.val() + "</td>" + "<td>" + telephone.val() + "</td>" + "<td>" + gender.filter(':checked').val() + "</td>" + "<td>" + nationality.val() + "</td>" + "</tr>");
                    $(this).dialog("close");
                }
    
            },
            Cancel : function() {
                $(this).dialog("close");
    
            }
        },
        close : function() {
            allFields.val("").removeClass("ui-state-error");
        }
    });
    
    $("#create-user").button().click(function() {
        $("#dialog-form").dialog("open");
    });
    });
    
    function check_exist(x, y, z, k) {
    jQuery.ajax({
        type : "POST",
        url : "inc/ajax.php?do=" + z,
        data : {y:x.val()},
        cache : false,
        success : function(response) {
            if (response == "1") {
                x.addClass("ui-state-error");
                updateTips(k);
                return false;
            }
            if (response == "0") {
                return true;
            }
        }
    });
    
    url : "inc/ajax.php",
        data : {do : z, y:x.val()},
    
    if(isset($_POST['do'])){
    
      if($_POST['do']=="userexist")
    }
    
            var notexist = true;
    
            notexist = notexist && check_exist(name, 'username', 'userexist', 'Login Name Already Exist!');
            notexist = notexist && check_exist(email, 'email', 'mailexist', 'E-Mail Already Exist!');
            if (bValid && notexist) `