Codeigniter - Update email only if the email doesn't exist in the database

前端 未结 3 786
借酒劲吻你
借酒劲吻你 2021-01-17 04:00

I have an update page for my users where they can edit their name, email and other info.

So far, they can edit everything. Including their email. They can enter an e

3条回答
  •  失恋的感觉
    2021-01-17 04:38

    use validate library : http://docs.jquery.com/Plugins/Validation/Methods/remote

    your javascript :

    $("#yourFormId").validate({
            rules: {
                email: {
                    required: true,
                    email: true,
                    remote: {
                        url: "checkmail.php",
                        type: "post"
                     }
                }
            },
            messages: {
                email: {
                    required: "Please Enter Email!",
                    email: "This is not a valid email!",
                    remote: "Email already in use!"
                }
            }
        });
    

    checkmail.php:

    
    

    if you use codeigniter means use checkmail.php as a controller function.. you can pass your $registeredEmails array values as $registeredEmails[] = "your query result which is in for loop".

提交回复
热议问题