簡體   English   中英

HTML表單未將數據傳遞到php處理器

[英]HTML Form not passing data to php processor

學習PHP,並通過以HTML形式將數據傳遞到PHP來解決問題。 當我點擊Submit時,表單頁面的行為就像它正確提交一樣,但是當processorder.php頁面打開時,數據不可見。 當我在頁面上進行轉儲時,我可以看到顯示的值,但是它們沒有顯示在腳本中。 下面是我正在使用的代碼。 我已經在網上和SO網站上進行搜索,覺得我已經用盡了所有選項。 您能提供的任何幫助將不勝感激。

HTML:
<form action="processorder.php" method="POST">

<table>
    <tr>
        <td>Item</td>
        <td>Quantity</td>
    </tr>
    <tr>
        <td>Tires</td>
        <td><input type="text" name="tireqty" id="tireqty" size="3" /></td>
    </tr>
    <tr>
        <td>Oil</td>
        <td><input type="text" name="oilqty" id="oilqty" size="3" /></td>
    </tr>
    <tr>
        <td>Spark Plugs</td>
        <td><input type="text" name="sparkqty" id="sparkqty" size="3" /></td>
    </tr>
    <tr>
        <td colspan="2" text-align"2"><input type="submit" value="Submit Order">
        </td>
    </tr>
</table>

</form>



PHP:
<?php

var_dump( $_POST );

/*var_dump($GLOBALS);*/

$tireqty = $_POST['$tireqty'];
$oilqty = $_POST['$oilqty'];
$sparkqty = $_POST['$sparkqty'];

/*echo phpinfo();*/

?>

<h1 />Bob's Auto Parts
<h2>Order Results</h2>

<?php

/*
ini_set('display_errors',1);  
error_reporting(E_ALL);
*/

   echo "<p>Your Order is as Follows: </p>";
   echo htmlspecialchars($tireqty).' tires<br />';  
   echo htmlspecialchars($oilqty).' bottles of oil<br />';
   echo htmlspecialchars($sparkqty).' spark plugs<br />';

    echo "<p>Order Processed at ";
    echo date('H:i, jS F Y');
    echo "</p>";

print_r($_POST);

/*var_dump($_REQUEST)*/

?>

刪除$ _POST方法中的$。 更改:

$tireqty = $_POST['$tireqty'];
$oilqty = $_POST['$oilqty'];
$sparkqty = $_POST['$sparkqty'];

至:

$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM