我是一名 PHP 程序员,我对下面的问题感到困惑,我正在等待您的指导。非常感谢!有html代码
<form action="" method="POST">
<div>
<strong>Release: *</strong> <input type="text" name="Release" value="<?php echo $rel; ?>" /><br/>
<strong>User Story ID: *</strong> <input type="text" name="User Story ID" value="<?php echo $id; ?>" /><br/>
<strong>Test Owner *</strong> <input type="text" name="Test Owner" value="<?php echo $owner; ?>" /><br/>
<strong>Date of TC Review *</strong> <input type="text" name="Date of TC Review" value="<?php echo $data; ?>" /><br/>
<strong>By Design </strong> <input type="text" name="By Design" value="<?php echo $design; ?>" /><br/>
<strong>By Review </strong> <input type="text" name="By Review" value="<?php echo $review; ?>" /><br/>
<strong>By Defect </strong> <input type="text" name="By Defect" value="<?php echo $defect; ?>" /><br/>
<p>* required</p>
<input type="submit" name="submit" value="Submit">
</div>
</form>
有php代码
if (isset($_POST['submit']))
{
// get form data, making sure it is valid
$release = mysql_real_escape_string(htmlspecialchars($_POST['Release']));
// $ID = " abc";
echo $_POST['Release'];
echo $_POST['User Story ID'];
$ID = mysql_real_escape_string(htmlspecialchars($_POST["User Story ID"]));
$T_Owner = mysql_real_escape_string(htmlspecialchars($_POST['Test Owner']));
$data = mysql_real_escape_string(htmlspecialchars($_POST['Date of TC Review']));
$T_ByDesign= mysql_real_escape_string(htmlspecialchars($_POST['By Design']));
$T_ByReview= mysql_real_escape_string(htmlspecialchars($_POST['By Review']));
$T_ByDefect= mysql_real_escape_string(htmlspecialchars($_POST['By Defect']));
// check to make sure both fields are entered
if ($release == '' || $ID == ''||$T_Owner==''||$data=='')
{
// generate error message
$error = 'ERROR: Please fill in all required fields!';
// if either field is blank, display the form again
renderForm($release, $ID, $T_Owner, $data, $T_ByDesign, $T_ByReview, $T_ByDefect, $error);
}
else
{
// save the data to the database
mysql_query("INSERT Tests SET T_Release='$release', ID='$ID',TestOwner='$T_Owner',T_Date='$data',Test_ByDesign='$T_ByDesign',Test_ByReview='$T_ByReview',Test_ByDefect='$T_ByDefect'")
or die(mysql_error());
// once saved, redirect back to the view page
header("Location: view.php");
}
}
错误信息如下:
Notice: Undefined index: User Story ID in C:\xampp\htdocs\Test\new.php on line 47
abc
Notice: Undefined index: User Story ID in C:\xampp\htdocs\Test\new.php on line 55
Notice: Undefined index: User Story ID in C:\xampp\htdocs\Test\new.php on line 56
Notice: Undefined index: Test Owner in C:\xampp\htdocs\Test\new.php on line 57
Notice: Undefined index: Date of TC Review in C:\xampp\htdocs\Test\new.php on line 58
Notice: Undefined index: By Design in C:\xampp\htdocs\Test\new.php on line 59
Notice: Undefined index: By Review in C:\xampp\htdocs\Test\new.php on line 60
Notice: Undefined index: By Defect in C:\xampp\htdocs\Test\new.php on line 61