PHP表单 - 如何根据单个下拉选项将用户定向到特定页面,AS WELL AS预先填充目标页面,其中包含一些给定的输入

Bit of a weird one (for me at least...)

I want to have the user complete a small form in order to proceed with an application for two different types of finance (name, email, contact etc). The user is also required to specify the type of finance they would like, and submitting the form takes the user to the full application for that finance type. I can already do this.

I also would like the input given in the initial form to be carried over to the full application. I can do this also.

My problem is, I can't get both of these features working together at the same time!

Initial Form:

<form method="post" action="form.starterApp.php" name="applyStart" id="applyStart">
    <table class="applyStart formTable" style="margin-right:20px;">
        <tr>
            <td colspan="2">
                <label for="ddAppType">Would you like to apply for Car Finance or a Logbook Loan?</label><br />
                <select name="ddAppType" id="ddAppType">
                    <option value="Car Finance">Car Finance</option>
                    <option value="Logbook Loan">Logbook Loan</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <label for="txtName">Your Name</label><br />
                <input name="txtName" type="text" id="txtName" value="" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <label for="txtEmail">Your Email</label><br />
                <input name="txtEmail" type="text" id="txtEmail" value="" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <label for="txtNumber">Your Contact Number</label><br />
                <input name="txtNumber" type="text" id="txtNumber" value="" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="chkAge" class="chkAge">Are you over 18 years of age?</label>
            </td>
            <td>
                <input type="checkbox" name="chkAge" id="chkAge" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" class="submit" id="submit" value="Submit" />
            </td>
        </tr>
    </table>
</form>

Action Script (form.starterApp.php):

<?php
    if(!$_POST) exit;

    // Only edit below this line if either instructed to do so by the author or have extensive PHP knowledge.
    // Please Note, we cannot support this file package if modifications have been made below this line.
    $ddAppType      = $_POST['ddAppType'];
    $txtName        = $_POST['txtName'];
    $chkAge         = $_POST['chkAge'];
    $txtEmail       = $_POST['txtEmail'];
    $txtNumber      = $_POST['txtNumber'];

    $ifFinance  = 'apply-for-finance';
    $ifLogbook  = 'apply-for-logbook';


    //Setting the Application Type
    if ($ddAppType == 'Car Finance') {
        $appType = $ifFinance;
    }
    else if ($ddAppType == 'Logbook Loan') {
        $appType = $ifLogbook;
    }

    {
        header( 'Location: '.$appType.'' );
    }
?>

Target page:

<form method="post" action="form.fullApplication.php" name="applyFinance" id="applyFinance">
<table class="applyFinance formTable" style="margin-right:20px;">
    <tr>
        <td colspan="2">
            <label for="txtName">Your Name</label><br />
            <input name="txtName" type="text" id="txtName" value="<?php echo $_POST["txtName"]; ?>" />
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <label for="txtEmail">Your Email</label><br />
            <input name="txtEmail" type="text" id="txtEmail" value="" />
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <label for="txtNumber">Your Contact Number</label><br />
            <input name="txtNumber" type="text" id="txtNumber" value="" />
        </td>
    </tr>
    <tr>
        <td>
            <label for="chkAge" class="chkAge">Are you over 18 years of age?</label>
        </td>
        <td>
            <input type="checkbox" name="chkAge" id="chkAge" />
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <input type="submit" class="submit" id="submit" value="Submit" />
        </td>
    </tr>
</table>

This is my first time posting on here, please forgive me if I have left out anything obvious and I will answer any questions as best I can.

Cheers!

You can try registering the ddAppType in session or in cookies.

Sessions and cookies let you register some values in some stage of the session and you can also retrieve them when you want (depening on the expiry time that you set for those values).