I have a PHP form which enters data into my MySQL database. My primary key is one of the user-entered values. When the user enters a value that already exists in the table,
You can check the return value from mysql_query when you do the insert.
mysql_query
$result = mysql_query("INSERT INTO mytable VALUES ('dupe')"); if (!$result) { echo "Enter a different value"; } else { echo "Save successful."; }