我正在製作一個註冊表單,其中php代碼和html表單在同一個頁面中,並且我還有一個驗證字段的java腳本,但如果驗證是完成後,我需要通過調用php發佈數據並提交數據庫如何使用表單提交一個php函數
if(isset($_POST['Name'])){
$order = "INSERT INTO `reg_form`(`Name`) VALUES ('$_POST[Name]')";
$result = mysql_query($order, $db2);
if (!$result) {
echo("<br>Input is failed");
} else {
echo 'Regestered successfully !!!';
}
}
<form name="register" id="register" class="b1 f_l" action="register.php" method="post">
<div class="input-group" style="padding-top: 20px;">
<span class="label_1">Name </span>
<input type="text" class="inp_t" placeholder="Your Name" name="Name" id="name" required>
</div>
<div style="padding-top: 20px;">
<button type="submit" class="btn btn-primary register" value="submit" >Submit</button>
</div>
</form>
<script language=JavaScript>
$('#register').validator()
.submit(function(e){
var form = $(this);
var valid = form.validator({messageClass: "alert alert-danger validate_error", position: 'center right'});
if (valid.data("validator").checkValidity()){
alert('not working');
}// VALID
e.preventDefault();
return false;
});// SUBMIT
</script>
您是否獲得了'不working'消息驗證功能? – SajithNair
是的,我得到 – user2926947