php - undefined variable : POST - PHP and MySQL

标签 php mysql

我有这样一个表格:

<form name="htmlform" method="post" action="script/gen.php?postData">
            <table width="450px">
                </tr>
                <tr>
                    <td valign="top">
                        <label for="customer">Customer:</label>
                    </td>
                    <td valign="top">
                        <input  type="text" name="customer" maxlength="50" size="30">
                    </td>
                </tr>

                <tr>
                    <td valign="top"">
                        <label for="nol">Number of licences: </label>
                    </td>
                    <td valign="top">
                        <input type="text" name="nol" maxlength="50" size="30">
                    </td>
                </tr>

                <tr>
                    <td>
                        <form method="post" id="submit" action="script/gen.php">
                            <input type="button" onClick="getKey()"; value="Generate key"/>
                    </td>
                </tr>



                <div id="innhold">
                            <h4>Licence Key: </h>
                </div>

                <tr>
                    <td colspan="2" style="text-align:center">
                        <input type="submit" value="Submit"> 
                    </td>
                </tr>

                </table>
            </form>

感兴趣的代码行是:

<input type="text" name="nol" maxlength="50" size="30">

<input  type="text" name="customer" maxlength="50" size="30">

我尝试像这样将此信息写入数据库:

function postData($key1) {
//just to check if the key is equal to the one thats posted to the user
//echo '<h5>From postData' . $key1 . '</h5>';
/*echo '<script type="text/javascript"> alert("The order has been submitted successfully");
location = "/Webpanel/index.html";
</script>';*/

$customerVar = $POST['customer'];
$nolVar = $POST['nol'];

mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("licencedatabase");

$query_add = "INSERT INTO licence (`customer_name`,`licence_count`) VALUES ('$customerVar','$nolVar')";
$query_exec = mysql_query($query_add) or die(mysql_error()); 
mysql_close();
}

但我一直收到错误:

Undefined variable: POST

我怎样才能做到这一点?提前致谢。

最佳答案

它的 $_POST不是 $POST

$customerVar = $_POST['customer'];
$nolVar = $_POST['nol'];

关于php - undefined variable : POST - PHP and MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11520795/

相关文章:

php - 相同的多域 session 但 session 值丢失

mysql - Silverstripe 2.4 - 3.1 升级 - innerJoin 'unknown column' 问题

php - mysql统计具有相同字段的结果

javascript - 使用 angularjs 和 JSON 从数据库获取数据

Mysql存储过程太慢

php - 使用 javascript 在 php 中保留 html post 数据

php - 圆形函数 - PHP

php - curl 错误 8 : Invalid Content-Length: value

php - 你如何缩小和/或压缩 php 文件中的 JavaScript?

MySql 查询与另一个查询分开