I tried to insert data using the following code, but I really I don't know how can I get result and what is the problem in my code, I tried to build firstly my form then I write the insert query and send it to a new form , any HELP please : Also I Have now the following error:

Notice: Undefined index: Services in C:\xampp\htdocs\ers\test.php on line 11

Notice: Undefined index: title in C:\xampp\htdocs\ers\test.php on line 12

Notice: Undefined index: RootCause in C:\xampp\htdocs\ers\test.php on line 13

Notice: Undefined index: RiskRating in C:\xampp\htdocs\ers\test.php on line 14

Notice: Undefined index: impact in C:\xampp\htdocs\ers\test.php on line 15

Notice: Undefined index: Efforts in C:\xampp\htdocs\ers\test.php on line 16

Notice: Undefined index: likelihood in C:\xampp\htdocs\ers\test.php on line 17

Notice: Undefined index: Finding in C:\xampp\htdocs\ers\test.php on line 18

Notice: Undefined index: Implication in C:\xampp\htdocs\ers\test.php on line 19

Notice: Undefined index: Recommendation in C:\xampp\htdocs\ers\test.php on line 20 Error: Cannot add or update a child row: a foreign key constraint fails (ers_1.findings, CONSTRAINT findings_ibfk_15 FOREIGN KEY (ServiceType_ID) REFERENCES servicetype_lookup (ServiceType_ID) ON UPDATE NO ACTION)
_____________________________________________________________________________________________________
This is my code :

<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> 

where is your SQL statement?
What uis the content of test.php?

Your form is incomplete, plus you have a FORM within a FORM. I do not beleive this is viable

As Squidge said you have a incomplete form, so end your form with a </form> tag. Also show us the test.php

This is my test.php

  <?php
$con = mysql_connect("localhost","root","mevooo");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("ers_1", $con);
$sql="INSERT INTO findings (Finding_ID, ServiceType_ID, Title, RootCause_ID, RiskRating_ID, Impact_ID, Efforts_ID, Likelihood_ID, Finding,Implication,  Recommendation, Report_ID) VALUES (
    '1',
    '$_POST[Services]',
    '$_POST[title]',
    '$_POST[RootCause]',
    '$_POST[RiskRating]',
    '$_POST[impact]',
    '$_POST[Efforts]',
    '$_POST[likelihood]',
    '$_POST[Finding]',
    '$_POST[Implication]',
    '$_POST[Recommendation]',
    '1'
    )";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con);
?> 
<input type="button" value="HOME" onclick="location='insert_Data.php'">

Please I want an urgent reply for my problem ..

Sorry was at work :)

I would suggest you take your $_POST data and extract it:

<?php
$con = mysql_connect("localhost","root","mevooo");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{
$services = $_POST['Services'];
$title = $_POST['title'];
$rootcause = $_POST['RootCause'];
$risk = $_POST['RiskRating'];
$impact = $_POST['impact'];
$efforts = $_POST['Efforts'];
$likelihood = $_POST['likelihood'];
$finding = $_POST['Finding'];
$implic = $_POST['Implication'];
$recom = $_POST['Recommendation'];
mysql_select_db("ers_1", $con);
$sql="INSERT INTO findings (Finding_ID, ServiceType_ID, Title, RootCause_ID, RiskRating_ID, Impact_ID, Efforts_ID, Likelihood_ID, Finding,Implication, Recommendation, Report_ID) VALUES ( 1, '$services','$title','$rootcause','$risk','$impact','$efforts','$likelihood','$finding','$implic','$recom', 1 )";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
else{
echo "1 record added";
}
}
mysql_close($con);
?>
<input type="button" value="HOME" onclick="location='insert_Data.php'">
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.