我尝试使用以下代码插入数据,但我真的不知道如何获得结果以及代码中的问题是什么,我尝试首先构建我的表单,然后编写插入查询并将其发送到新表格,请提供任何帮助:我现在也有以下错误:
注意:未定义索引:第 11 行 C:\xampp\htdocs\ers\test.php 中的服务
注意:未定义索引:第 12 行 C:\xampp\htdocs\ers\test.php 中的标题
注意:未定义的索引:第 13 行 C:\xampp\htdocs\ers\test.php 中的 RootCause
注意:未定义索引:第 14 行 C:\xampp\htdocs\ers\test.php 中的 RiskRating
注意:未定义索引:第 15 行 C:\xampp\htdocs\ers\test.php 中的影响
注意:未定义索引:第 16 行 C:\xampp\htdocs\ers\test.php 中的努力
注意:未定义的索引:第 17 行 C:\xampp\htdocs\ers\test.php 中的可能性
注意:未定义的索引:在第 18 行的 C:\xampp\htdocs\ers\test.php 中查找
注意:未定义索引:第 19 行 C:\xampp\htdocs\ers\test.php 中的含义
注意:未定义索引:第 20 行 C:\xampp\htdocs\ers\test.php 中的建议错误:无法添加或更新子行:外键约束失败 ( ers_1
. findings
, CONSTRAINT findings_ibfk_15
FOREIGN KEY ( ServiceType_ID
) REFERENCES servicetype_lookup
( ServiceType_ID
) ON UPDATE不采取行动)
<html>
<body>
<?php
$con = mysql_connect("localhost","root","123");
error_reporting(0);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>
<form method="post" action="test.php">
<fieldset>
<legend>Insert New Data </legend>
<p> Service Name :
<select name="Services">
<option value="select"> -Select- </option>
<option value="architecture review">Architecture Review</option>
<option value="internal penetration testing">Internal Penetration Testing</option>
<option value="network component review">Network Component Review</option>
<option value="database review">Database Review</option>
<option value="wireless network">Wireless Network</option>
<option value="operating system review">Operating System Review</option>
<option value="web application">Web Application</option>
<option value="external penetration testing">External Penetration Testing</option>
</select>
</p>
<form method="post" action="test.php">
Ref : <input type="text" name="ref" /><br />
Title : <input type="text" name="title" /><br />
Risk Rating :
<select name="RiskRating">
<option value="select"> -Select- </option>
<option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>
</select><br />
Root Cause :
<select name="RootCause">
<option value="select"> -Select- </option>
<option value="access control">Access Control</option>
<option value="configuration management">Configuration Management</option>
<option value="patch management">Patch Management</option>
<option value="patch management">Certificate Management</option>
<option value="patch management">Password Management</option>
<option value="patch management">Audit Trail and Security Logs Management</option>
<option value="service deployment">Network Management</option>
</select><br />
Impact :
<select name="impact">
<option value="select"> -Select- </option>
<option value="high"> Major </option>
<option value="moderate"> Moderate </option>
<option value="low"> Minor </option>
</select><br />
Likelihood :
<select name="likelihood">
<option value="select"> -Select- </option>
<option value="possible"> Likely </option>
<option value="impossible">Possible</option>
<option value="definite"> Moderate </option>
<option value="definite"> Rare </option>
</select><br/>
Efforts :
<select name="Efforts">
<option value="select"> -Select- </option>
<option value="possible"> Significant </option>
<option value="impossible">Moderate </option>
<option value="definite"> Intermediate </option>
<option value="definite"> Simple </option>
</select><br/>
Finding : <br/>
<TEXTAREA NAME="Finding" COLS=100 ROWS=10>
</TEXTAREA>
<br/>
Implication: <br/>
<TEXTAREA NAME="Implication" COLS=100 ROWS=10>
</TEXTAREA>
<br/>
Recommendation : <br/>
<TEXTAREA NAME="Recommendation" COLS=100 ROWS=10>
</TEXTAREA>
<br/><input type="submit" value=" Save " onclick="window.location.href='test.php'" />
</fieldset>
</form>
<?php
mysql_select_db("ers_1", $con);
$result = mysql_query("SELECT * FROM findings");
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Finding_ID'] . "</td>";
echo "<td>" . $row['ServiceType_ID'] . "</td>";
echo "<td>" . $row['Title'] . "</td>";
echo "<td>" . $row['RootCause_ID'] . "</td>";
echo "<td>" . $row['RiskRating_ID'] . "</td>";
echo "<td>" . $row['Impact_ID'] . "</td>";
echo "<td>" . $row['Efforts_ID'] . "</td>";
echo "<td>" . $row['Likelihood_ID'] . "</td>";
echo "<td>" . $row['Finding'] . "</td>";
echo "<td>" . $row['Implication'] . "</td>";
echo "<td>" . $row['Recommendation'] . "</td>";
echo "<td>" . $row['Report_ID'] . "</td>";
echo "<td><a href='edit.php'>[EDIT]</a> <a href='delete_risk.php?risk_no=" . $row['risk_no'] . "'>[DELETE]</a></td>";
echo "</tr>";
}
mysql_close($con);
?>
</body>
</html>