如何在PHP中调试“未定义的索引”警告?

时间:2015-10-14 03:04:26

标签: php

insert.php page

<body>
<h1>Insert Form</h1>
<p>This will be used to insert fields to the database</p>

<form name="insert_form" method="post" action="insertprocess.php">
t ID: <input name="testID" type="text" disabled><br>
t Name: <input name="testNAME" type="text"><br>
<button type="submit" name="submit">Submit</button>
</form>

</body>
</html>

insertprocess.php page

<?php
include("config.inc.php");

mysql_query("INSERT INTO test (test_ID, test_NAME) VALUES ('".$_POST['test_ID']."','".$_POST['test_NAME']."')");

?>

这是我得到的错误。

  

注意:未定义的索引:第4行的C:\ inetpub \ wwwroot \ Test \ insertprocess.php中的test_ID注意:未定义的索引:第4行的C:\ inetpub \ wwwroot \ Test \ insertprocess.php中的test_NAME

1 个答案:

答案 0 :(得分:2)

testNAME$_POST['test_NAME']不同,同样适用于testID $_POST['test_ID ']

更改为:

$_POST['testNAME']
$_POST['testID']