0

当我尝试提交值时,它显示“服务器错误”。

在我的第一个文件index.php中,我有这个,然后我让它提交给另一个文件,也许它也可以提交给自己?

<html>
<body>

<h1>Sale Calculator </h1>

<form action="process.php" method="post">

Cost of item:

<input type="text" name="itemAmt" required="required" />

Percentage of discount:

<select name="saleAmt">
<option value="5">5% off</option>
<option value="10">10% off</option>
<option value="15">15% off</option>
<option value="20">20% off</option>
<option value="25">25% off</option>
<option value="30">30% off</option>
<option value="40">40% off</option>

<!-- Ill fill out more values later -->

</select>

<input type="submit" name="submit" value="submit">

</form>

</body>
</html>

**Then in the second php file process.php I have put this:**



 <?php
    $itemAmt = $_POST['itemAmt'];
    $saleAmt = $_POST['saleAmt'];
    $dollarSaleAmt;
    $totalCost;

    function calculateDiscount($itemAmt, $saleAmt, &$dollarSaleAmt, &$totalCost)
    {

    $dollarSaleAmt = $itemAmt * ($saleAmt / 100);
    $totalCost = $itemAmt – $dollarSaleAmt;
    }

    calculateDiscount($itemAmt, $saleAmt, $dollarSaleAmt, $totalCost);
    ?>

    <html>
    <body>
    The total discount <?php echo $_POST['itemAmt']; ?> .

    <br />

    The final cost minus the discount of <?php echo $_POST['saleAmt']; ?> .

    <br />
    Discount
    <?php echo $dollarSaleAmt; ?>
    <br />
    Total value:
    <?php echo $totalCost; ?>
    </body>
    </html>
4

1 回答 1

2
于 2012-09-12T02:11:00.620 回答