在php

时间:2016-09-26 18:02:00

标签: php jquery

我有一个使用jquery表单验证来更改用户电子邮件的表单。我遇到的问题是当用户提交值时发布但我无法在我的php文件中捕获它。它总是打印空

以下是我的代码

$("#change_email").validate({
    rules: {
        "new_email": {
            required:true,
            email: true
        },
        "confirm_email": {
            required: true,
            equalTo : "#email"
        }
    },
    messages: {
        "new_email": {
            required: "required",
            email: "invalid"
        },
        "confirm_email": {
            required: "not match",

        }
    },
    submitHandler: function (form) { 
        var formd = $(form).serialize();
        $.ajax({
            url: 'http://localhost/secular/change_email',
            type: 'POST',
            data: formd,
            async: false,
            success: function(data) {
                alert(data);
            },
            error: function(data){
                console.log("error");
            });
         return false;
    }
});

HTML

<form id="change_email">
    <div class="form-group">
        <label class="control-label col-sm-3">New Email :</label>
        <div class="col-sm-4">
            <input type="text" name="new_email" id="email" class="form-control" required>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-3">Confirm Email:</label>
        <div class="col-sm-4">
            <input type="text" name="confirm_email"  class="form-control" required>
        </div>
    </div>
    <input class="btn btn-primary" value="Save" type="submit">
</form>

PHP

function change_email()
{
    echo $email = $this->input->post('new_email');
}

当我检查萤火虫时,它发布如下

new_email=test%40test.com&confirm_email=test%40test.com

有人可以告诉我这里我做错了什么吗?

编辑:在Firebug中查看,特别是回复:

enter image description here

0 个答案:

没有答案