jQuery表单向导没有提交

时间:2015-11-11 12:33:42

标签: javascript php jquery forms

我有一个表单通过jQuery表单向导,而不是发布到数据库中。我是js的新手,但试图找到我的方法来完成这件事。

我的问题是POST数据没有到达数据库。 在submit我已经将下面的代码发送到数据库。

这是我的js代码

$('#form_wizard_1').bootstrapWizard({
    'nextSelector': '.button-next',
    'previousSelector': '.button-previous',
    onTabClick: function (tab, navigation, index, clickedIndex) {
        success.hide();
        error.hide();
        if (form.valid() == false) {
            return false;
        }
        handleTitle(tab, navigation, clickedIndex);
    },
    onNext: function (tab, navigation, index) {
        success.hide();
        error.hide();

        if (form.valid() == false) {
            return false;
        }

        handleTitle(tab, navigation, index);
    },
    onPrevious: function (tab, navigation, index) {
        success.hide();
        error.hide();

        handleTitle(tab, navigation, index);
    },
    onTabShow: function (tab, navigation, index) {
        var total = navigation.find('li').length;
        var current = index + 1;
        var $percent = (current / total) * 100;
        $('#form_wizard_1').find('.progress-bar').css({
            width: $percent + '%'
        });
    }
});

$('#form_wizard_1').find('.button-previous').hide();
$('#form_wizard_1 .button-submit').click(function () {
    $.ajax({
        url:'reg_post.php',
        data:$('#submit_form').serialize(),
        data : { appraiseid : $("#appraiseid").val() },
        type:'POST',
        success:function(data){
            console.log(data);
            $(".alert-success").show().fadeOut(5000);
        },
        error:function(data){
            $(".alert-danger'").show().fadeOut(5000);
        }
    });
}).hide();

腓:

<?php
$conn = mysql_connect("localhost","root","");
mysql_select_db("church",$conn); 
if(!empty($_POST['userename'])) { 
    $appraisename = htmlspecialchars(trim($_POST["userename"]));
} 
$form1sql = "INSERT INTO reg (username) VALUES('".$appraisename."') ";
mysql_query($form1sql) or die(mysql_error()); 
?>

HTML:

它是一个很长的形式,但试图先发布一个字段。然后可以从那里继续前进。 HTML&amp; JS工作正常。它只是发布到数据库中。

0 个答案:

没有答案