简体   繁体   English

HTML表单未将数据传递到php处理器

[英]HTML Form not passing data to php processor

learning PHP and have hit a wall early with passing data in an HTML form in to PHP. 学习PHP,并通过以HTML形式将数据传递到PHP来解决问题。 When I hit submit, the form page acts like it submits properly but when the processorder.php page opens, the data is not visible. 当我点击Submit时,表单页面的行为就像它正确提交一样,但是当processorder.php页面打开时,数据不可见。 When I do a dump on the page, I am able to see the values displayed but they are not showing in the script. 当我在页面上进行转储时,我可以看到显示的值,但是它们没有显示在脚本中。 Below is the code I'm using. 下面是我正在使用的代码。 I've searched online and at SO and feel like I've pretty much exhausted all options. 我已经在网上和SO网站上进行搜索,觉得我已经用尽了所有选项。 Any assistance you can provide is much appreciated. 您能提供的任何帮助将不胜感激。

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)*/

?>

Remove the $ of your $_POST methods. 删除$ _POST方法中的$。 Change: 更改:

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

to: 至:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM