PHP post表单的多个输入元素

时间:2014-05-13 22:49:26

标签: php html post input

我的申请表格有3个不同的阶段,并且使用<input type="button">有2个按钮但是在提交表单时,使用最后一个按钮,它只会保存应用程序的第三部分,怎么做我得到前两部分表单元素?!

<form action="" method="post">
<section class="mainSection">
    <section class="firstStep">
        <header class="firstStepheader">
            Step 1: Your Details
        </header>

        <section class="firstStepDetails">
            <div class="left">
                <h1>First Name:</h1>
                <input name="firstName" id="firstName" tabindex="1">
                <h2 id="fNameError">Please enter your first name</h2>
                <h1>Email Address:</h1>
                <input name="emailAddress" id="emailAddress" tabindex="3">
                <h2 id="emailError">Please enter your email address</h2>
            </div>
            <div class="right">
                <h1>Surname:</h1>
                <input name="surName" id="surName" text=""  tabindex="2">
                <h2 id="sNameError">Please enter your surname</h2>
            </div>
            <input class="nextButton" id="firstNextButton" value="Next >" type="button">
        </section>
    </section>

    <br>

    <section class="secondStep">
        <header class="secondStepheader">
            Step 2: More Details
        </header>

        <section class="secondStepDetails">
            <div class="left">
                <h1>Telephone Number</h1>
                <input name="telNo" text="" id="telNo"  tabindex="1">
                <h2 id="telNoError">Please enter your telephone number</h2>

                <h1>Gender</h1>
                <select id="gender" tabindex="3">
                    <option id="male">Male</option> 
                    <option id="female">Female</option>
                </select>
            </div>
            <div class="right">
                <h1>Date of Birth</h1>
                <input name="dOB" text="" id="dOB" tabindex="2"><h3>Format: DD/MM/YYYY</h3>
                <h2 id="dOBError">Please enter a valid date</h2>
            </div>
            <input class="nextButton" id="secondNextButton" value="Next >" type="button">
        </section>
    </section>

    <br>

    <section class="thirdStep">
        <header class="thirdStepheader">
            Step 3: Comments Section
        </header>

        <section class="thirdStepDetails">
            <div class="left">
                <h1>Comments</h1>
                <textarea name="telNo" text="" cols="50"></textarea>
            </div>
            <button class="nextButton" id="submitButton" type="submit">Submit ></button>
        </section>
    </section>
</section>
</form>

2 个答案:

答案 0 :(得分:0)

如果您需要多个按钮,则需要使用AJAX来处理多个部分的表单。否则,最后只需使用一个按钮。最后一个按钮将通过$_POST发送所有内容,您可以捕获它并随意处理它。

答案 1 :(得分:0)

发现我在JQuery中禁用了输入,这意味着不会发布元素。