I have a form through the jQuery Form Wizard and its not posting into the database. Am a novice of js but trying to find my way out to just get this done.
My issue is that the POST data doesnt get to the database.
On submit
I have put the below code to send the data to the database.
This is my js code
$('#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:
<?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:
Its a long form but trying to post one field first. Then can move on from there. The HTML & JS works fine. its just to post into the database.