Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未定义变量:POST-PHP和MySQL_Php_Mysql - Fatal编程技术网

未定义变量:POST-PHP和MySQL

未定义变量:POST-PHP和MySQL,php,mysql,Php,Mysql,我有一张这样的表格: <form name="htmlform" method="post" action="script/gen.php?postData"> <table width="450px"> </tr> <tr> <td valign="top">

我有一张这样的表格:

<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>
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();
}

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

要访问超全局POST,请使用
$\u POST
not
$POST
这是因为它被称为
$\u POST
它不是
$POST

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

尝试使用
$\u POST
而不是
$POST

所有PHP超全局变量(例如GET和POST)都以下划线作为前缀,因此:
$POST
应该是
$\u POST

有关PHP中可用的超全局变量的更多信息,请查看此处:

尝试使用
$\u POST
而不是
$POST

检查以下示例:

预定义的
$\u POST
变量用于从使用
method=“POST”
发送的表单中收集值

使用POST方法从表单发送的信息对其他人不可见,并且对发送的信息量没有限制

示例:

<form action="submitform.php" method="post">
    Name: <input type="text" name="fname" />
    Age:  <input type="text" name="age" />
    <input type="submit" />
</form>

您可能会明白。

我正在使用notepad++和WAMP进行本地测试,并使用Firebug插件进行chrome测试。在google上进行快速简单的搜索会立即给出答案……所有mysql_*功能都已弃用,如图所示:不鼓励使用此扩展。相反,应该使用or扩展名。
Undefined variable: POST
$customerVar = $_POST['customer'];
$nolVar = $_POST['nol'];
<form action="submitform.php" method="post">
    Name: <input type="text" name="fname" />
    Age:  <input type="text" name="age" />
    <input type="submit" />
</form>
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?>  years old.