如何才能以多种形式处理所选输入?

时间:2016-05-20 02:37:57

标签: php shopping-cart

如何才能以多种形式处理所选输入? isset()?...我想要"购物者"选择每种"样式的数量"他们想要并点击提交。 链接:http://taketwodesigns.com/monkeypod/order/index.php  然后将它们发送到确认页面并通过电子邮件发送该页面。我会有很多项目样式,每种样式最多6个。我目前在一个单独的表单中有每个项目样式(并提交正常)。 我尝试只使用1个表单来提交多个样式,但这样做并不起作用,因为我使用了"必需"属性。 当我只提交1种风格时,它显示"必需"对于未选中的任何字段..(使用单一表单方法时) 只提交1张表格对我来说很棒!谢谢!

<form action="process/process_mlv101_207bk.php" method="post" name="orderform1" class="margins">
    <a href="images/styles/large/mh800bk_big.jpg" target="_blank"><img class="thumb_align" src="images/styles/thumbs/mh800bk_thumb.jpg" /></a>
    <table border="1" cellspacing="1">
        <tr class="gridaddrows">
            <td colspan=8 class="radius">
                <span class="formtext"><b>You must click the "Add to Cart" button to place items in cart.</b></span>
            </td>
        </tr>
        <tr class="gridrows">
            <td class="gridtitle">Add</td>
            <td class="gridtitle">XS</td>
            <td class="gridtitle">S</td>
            <td class="gridtitle">M</td>
            <td class="gridtitle">L</td>
            <td class="gridtitle">XL</td>
            <td class="gridtitle">2XL</td>
        </tr>
        <td class="add_to_cart_btn">
            <input type="image" src="../order/images/clicktoadd83pxfast.gif" alt="Add to Cart" />
        </td>
        <td>
            <input type="number" name="mlv101_207bkxs" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
        <td>
            <input type="number" name="mlv101_207bksm" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
        <td>
            <input type="number" name="mlv101_207bkmd" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
        <td>
            <input type="number" name="mlv101_207bklg" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
        <td>
            <input type="number" name="mlv101_207bkxl" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
        <td>
            <input type="number" name="mlv101_207bkxxl" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
    </table>
</form>
<!----------- 2ND STYLE BELOW ---------------->
<form action="process/process_mmt101_107bk.php" method="post" name="orderform1" class="margins">
    <a href="images/styles/large/mmt101-107bk_big.jpg" target="_blank"><img class="thumb_align" src="images/styles/thumbs/mmt101-107bk_thumb.jpg" /></a>
    <table border="1" cellspacing="1">
        <tr class="gridaddrows">
            <td colspan=8 class="radius">
                <span class="formtext"><b>You must click the "Add to Cart" button to place items in cart.</b></span>
            </td>
        </tr>
        <tr class="gridrows">
            <td class="gridtitle">Add</td>
            <td class="gridtitle">XS</td>
            <td class="gridtitle">S</td>
            <td class="gridtitle">M</td>
            <td class="gridtitle">L</td>
            <td class="gridtitle">XL</td>
            <td class="gridtitle">2XL</td>
        </tr>
        <td class="add_to_cart_btn">
            <input type="image" src="../order/images/clicktoadd83pxfast.gif" alt="Add to Cart" />
        </td>
        <td>
            <input type="number" name="mmt101_107bkxs" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
        <td>
            <input type="number" name="mmt101_107bksm" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
        <td>
            <input type="number" name="mmt101_107bkmd" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
        <td>
            <input type="number" name="mmt101_107bklg" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
        <td>
            <input type="number" name="mmt101_107bkxl" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
        <td>
            <input type="number" name="mmt101_107bkxxl" placeholder="Qty" min="0" max="288" required autocomplete="off">
        </td>
    </table>
</form>

<!------------ 3RD STYLE BELOW etc... ------------>

<!-----------PHP BELOW ---------->

<?php

$mlv101_207bkxs  = $_POST['mlv101_207bkxs'];
$mlv101_207bksm  = $_POST['mlv101_207bksm'];
$mlv101_207bkmd  = $_POST['mlv101_207bkmd'];
$mlv101_207bklg  = $_POST['mlv101_207bklg'];
$mlv101_207bkxl  = $_POST['mlv101_207bkxl'];
$mlv101_207bkxxl = $_POST['mlv101_207bkxxl'];

if(isset($_POST['mlv101_207bkxs'],
         $_POST['mlv101_207bksm'],
         $_POST['mlv101_207bkmd'],
         $_POST['mlv101_207bklg'],
         $_POST['mlv101_207bkxl'],
         $_POST['mlv101_207bkxxl'] )){    

$mlv101_207bkxs  = ltrim($mlv101_207bkxs, '0');
$mlv101_207bksm  = ltrim($mlv101_207bksm, '0');
$mlv101_207bkmd  = ltrim($mlv101_207bkmd, '0');
$mlv101_207bklg  = ltrim($mlv101_207bklg, '0');
$mlv101_207bkxl  = ltrim($mlv101_207bkxl, '0');
$mlv101_207bkxxl = ltrim($mlv101_207bkxxl, '0');

    echo '<p class="great">Thank you for your order!</p>';

    echo "<ul><h3>Ordered Items Below</h3><h4>Item# MLV101-207BK</h4>";

    echo "<li>" . $mlv101_207bkxs .  "&nbsp; -&nbsp; X-Small" . "</li>";
    echo "<li>" . $mlv101_207bksm . "&nbsp; -&nbsp; Small" . "</li>";
    echo "<li>" . $mlv101_207bkmd . "&nbsp; -&nbsp; Medium" . "</li>";
    echo "<li>" . $mlv101_207bklg . "&nbsp; -&nbsp; Large" . "</li>";
    echo "<li>" . $mlv101_207bkxl . "&nbsp; -&nbsp; X-Large" . "</li>";
    echo "<li>" . $mlv101_207bkxxl . "&nbsp; -&nbsp; XX-Large" . "</li>";

    echo "</ul>";
    }
?>

0 个答案:

没有答案