Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMUZ140306 Blessing Muhakichi
1,627 PointsDuplicate entry for key 1 in php and mysql
the forms are below:
<form name="personal__details" method="post" action="connect.php" class="form1">
<fieldset class="boundary1">
<legend> Personal details:</legend>
<p>first name:<input type="text" name="first_name"/> </p>
<p>surname<input type="text" name="surname"/> </p>
<p>DOB:<input type="text" name="DOB"/> </p>
<p>id number:<input type="text" name="id_number"/> </p>
<p>telephone number:<input type="text" name="telephone_number"/> </p>
<p>residential address:<input type="text" name="telephone_number"/> </p>
<p>email address:<input type="text" name="email_address"/> </p>
<p>sex:<input type="text" name="sex"/> </p>
<p>birth place:<input type="text" name="birth_place"/> </p>
<p>nationality:<input type="text" name="nationality"/> </p>
<p>marital status:<input type="text" name="marital_status"/> </p>
</fieldset><br>
<input type="submit" name="submit" value="submit" class="submits">
</form>
<p>IF you are married, fill in your spouse's details in the form provided below</p>
<form name="spouse__details" method="post" action="connect.php" class="form2">
<fieldset class="boundary2">
<legend> Spouse details:</legend>
<p>first name:<input type="text" name="first_name"/> </p>
<p>surname<input type="text" name="surname"/> </p>
<p>DOB:<input type="text" name="DOB"/> </p>
<p>brief description:<input type="text" name="brief_description"/></p>
<p>birth place:<input type="text" name="birth_place"/> </p>
</fieldset><br>
<input type="submit" name="submit" value="submit">
</form>
<p>If you have any dependant children, give their ddetails below</p>
<form name="dependant_children" method="post" action="connect.php" class="form3">
<fieldset class="boundary3">
<legend> Dependant children:</legend>
<p>name:<input type="text" name="name"/> </p>
<p>sex<input type="text" name="sex"/> </p>
<p>DOB:<input type="text" name="DOB"/> </p>
<p>school attended:<input type="text" name="school_attended"/></p>
<p>other dependancies:<input type="text" name="other_dependancies"/> </p>
</fieldset><br>
<input type="submit" name="submit" value="submit">
</form>
<p>Fill your next of kin details on the form provided below</p>
<form name="next_of_kin" method="post" action="connect.php" class="form4">
<fieldset class="boundary4">
<legend> Next of kin:</legend>
<p id="p1">name:<input type="text" name="name"/> </p>
<p>contact_address<input type="text" name="contact_address"/> </p>
<p>telephone_number:<input type="text" name="telephone_number"/> </p>
<p>relationship:<input type="text" name="relationship"/></p>
</fieldset><br>
<input type="submit" name="submit" value="submit">
</form><br>
<p><strong>If you are a member of any medical aid society, give details on the forms provided.</strong></p>
<form action="recruitment_page.php" method="POST">
Medical aid title:<input type="text" name="name"><br>
<textarea name="comment"></textarea><br>
<input type="submit" name="submit" value="submit">
</form>
AND TH TABLES ARE BELOW:
<?php
/****************** PERSONAL_DETAILS TABLE****************************/
$submit = $_POST['submit'];
$id = $_POST['id'];
$first_name = $_POST['first_name'];
$surname = $_POST['surname'];
$DOB = $_POST['DOB'];
$id_number = $_POST['id_number'];
$telephone_number = $_POST['id_number'];
$residential_address = $_POST['residential_address'];
$email_address = $_POST['email_address'];
$sex = $_POST['sex'];
$birth_place = $_POST['birth_place'];
$nationality = $_POST['nationality'];
$marital_status = $_POST['marital_status'];
if ($submit)
{
$connect = mysql_connect("localhost","root","");
mysql_select_db("manifestdb",$connect);
$query = mysql_query("INSERT INTO personal_details VALUES('$first_name','$surname','$DOB','$id_number','$telephone_number','$residential_address','$email_address','$sex','$birth_place','$nationality','$marital_status')") or die(mysql_error());
?>
<script language="javascript">
alert("data saved, Fill the following forms")
location=('recruitment_page.php')
</script>
<?php
}
?>
<?php
/******************* SPOUSE_DETAILS TABLE *********************/
/*$connect = mysql_connect("localhost","root","");
mysql_select_db("manifestdb",$connect); */
$submit = $_POST['submit'];
$id = $_POST['id'];
$first_name = $_POST['first_name'];
$surname = $_POST['surname'];
$DOB = $_POST['DOB'];
$brief_description = $_POST['brief_description'];
$birth_place = $_POST['birth_place'];
if ($submit)
{
$connect = mysql_connect("localhost","root","");
mysql_select_db("manifestdb",$connect);
$query = mysql_query("INSERT INTO spouse_details VALUES('$first_name','$surname','$DOB','$brief_description','$birth_place')");
die(mysql_error());
?>
<script language="javascript">
alert("data saved, Fill the following forms")
location=('recruitment_page.php')
</script>
<?php
}
?>
<?php
/************************* DEPENDANT_CHILDREN TABLE***********************************/
/*$connect = mysql_connect("localhost","root","");
mysql_select_db("manifestdb",$connect); */
$submit = $_POST['submit'];
$id = $_POST['id'];
$name = $_POST['name'];
$sex = $_POST['sex'];
$DOB = $_POST['DOB'];
$school_attended = $_POST['school_attended'];
$other_dependencies = $_POST['other_dependencies '];
if ($submit)
{
$connect = mysql_connect("localhost","root","");
mysql_select_db("manifestdb", $connect);
$query = mysql_query("INSERT INTO dependant_children VALUES('$name','$sex','$DOB','$school_attanded','$other_dependencies')");
die(mysql_error());
?>
<script language="javascript">
alert("data saved, Fill the following forms")
location=('recruitment_page.php')
</script>
<?php
}
?>
<?php
/***********************NEXT_OF_KIN TABLE****************************/
/*$connect = mysql_connect("localhost","root","");
mysql_select_db("manifestdb",$connect); */
$submit = $_POST['submit'];
$id = $_POST['id'];
$name = $_POST['name'];
$contact_address = $_POST['contact_address'];
$telephone_number = $_POST['telephone_number'];
$relationship= $_POST['relationship'];
if ($submit)
{
$connect = mysql_connect("localhost","root","");
mysql_select_db("manifestdb", $connect);
$query = mysql_query("INSERT INTO next_of_kin VALUES('$name','$contact_address','$telephone_number','$relationship')");
die(mysql_error());
?>
<script language="javascript">
alert("data saved, Fill the following forms")
location=('recruitment_page.php')
</script>
<?php
}
?>
1 Answer
thomascawthorn
22,986 PointsI think we're going to need a bit more information on your problem! I.e. do you know which line the error is coming from? Have you got any key constraints set up in the database? It's definitely more helpful than dumping your entire code into the question! ;)