i want to add records to table 'pool' with attribute ID and empName from database employees
theform.html
<FORM NAME ='form2' METHOD ='POST' ACTION ='result.php' enctype="multipart/form-data">
<B>Board Write</B> <BR>
<INPUT TYPE = Text Name = empID value = 'write ID here'>
<INPUT TYPE = Text Name = empName VALUE = 'write name here'><P>
<INPUT TYPE = 'Submit' Name = Submit2 VALUE = 'Post'>
</FORM>
result.php
<?PHP
$ID = $_POST['empID'];
$NAME = "'" . $_POST['empName'] . "'";
$server = "127.0.0.1"; //connect to server
$user_name = "root";
$password = "";
$database = "employees";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
if($db_found){// there is a database
$tableSQL = "INSERT INTO pool(ID, empName) VALUES " . "(" . $ID . "," . $NAME . ")";
$result = mysql_query($tableSQL);
if($result){
print "success!";
}
else{
print "fail!";
}
}
mysql_close($db_handle); //close the connection;
?>
in the database, ID is unique and also an INT datatype, i want to catch the error code where the user inputs an ID value that already existing in the database. how do we do this?