我正在使用 Bootstrap 签名表单,并且正在使用以下代码:
$.ajax({
type: "POST",
url: 'process/register.php',
data: $(this).serialize(),
dataType: "html",
success: function(msg){
alert('23');
},
error: function(error) {
console.log("an error", error);
}
});
然而什么也没发生。表单有效,数据库有新添加,但回调永远不会运行。
根据要求,这是register.php
代码:
$email = $_POST['Email_address'];
$pword = $_POST['Password'];
$pword = md5($pword);
$result = $db->query("INSERT INTO users (`name`,`password`) VALUES ('" . $email . "','" . $pword . "')");
if($result != FALSE){
echo "true";
} else {
echo "false";
}
echo "!!!!!!!!!!";
如果有帮助,这里是 HTML 表单代码:
<form class="form-signin" method="post" enctype="multipart/form-data" action="" id="regForm">
<h2 class="form-signin-heading" style="width:500px;">Register</h2>
<input type="text" class="form-control" placeholder="Email address" name="Email_address" id="Email_address" autofocus required>
<input type="password" class="form-control" placeholder="Password" name="Password" id="Password" required><br>
<button class="btn btn-lg btn-primary btn-block" type="submit" id="regSubmit">Register</button>
</form>