如何以多步骤形式提交表单并插入数据库
我制作了一个类似于多步骤上一个下一个按钮的表单,也是使用js制作的。现在我想提交表单并在 php 中发送到数据库
表单 HTML:
<form action="method.php" method="post" name="htlregistration_F" id="htlregistration_F" enctype="multipart/form-data" >
<section id="form_part1" class="tab" >
<h3 class="bodytext bodyheading " ><strong>Applicant Details</strong></h3>
<label class="bodytext">Applicant First Name<span class="redtext"> *</span>
<input name="appfirstname_f" type="text" id="appfirstname_f" class="input form-control" maxlength="25" required>
<span class="redtext" id="errorFirst" >(Max length 25 chars)</span>
</label>
</section>
<section id="form_part4" class="tab " >
<h3 class="bodytext bodyheading " ><strong>Contact Details</strong></h3>
<label class="bodytext" >Phone (Mobile)<span class="redtext" id="errorMobile"> *</span>
<input name="phmob_f" type="text" id="phmob_f" class="input form-control" minlength="10" maxlength="10" required="">
<span class="redtext">(Max length 10 chars)</span>
</label>
</section>
<div style="overflow:auto;">
<div style="float:right;">
<button type="button" id="prevBtn" onclick="nextPrev(-1)">« Previous</button>
<button type="button" id="nextBtn" name="licensesubmit" onclick="nextPrev(1)">» Next </button>
</div>
</div>
</form>
我的页面脚本
<script>
var currentTab = 0; // Current tab is set to be the first tab (0)
showTab(currentTab); // Display the current tab
function showTab(n) {
// This function will display the specified tab of the form...
var x = document.getElementsByClassName("tab");
x[n].style.display = "block";
//... and fix the Previous/Next buttons:
if (n == 0) {
document.getElementById("prevBtn").style.display = "none";
} else {
document.getElementById("prevBtn").style.display = "inline";
}
Smart猫小萌