I'm not sure if this is the most efficient way to do it, but this is what I do.
I'm assuming your form submits to a new page, but it isn't that hard to do it all in one page either using isset.
On the page that gets the form information, lets say you don't want duplicate IDs being inserted (this works for other ways too, just change from ID), then you just check to see if there are any rows with that ID.
$current_id = $_POST['form_id'];
$query_find = "SELECT * FROM `table` WHERE `id` = '$current_id'"
$find = mysql_query($query_find, $connection) or die(mysql_error());
$num_rows_find = mysql_num_rows($find);
if($num_rows_find < 1) {
$query_insert = "INSERT INTO `table` ... the information";
$insert = mysql_query($query_insert, $connection) or die(mysql_error());
}
else {
$query_update = "UPDATE `table` SET ...the information... WHERE `id` = '$current_id'";
$update = mysql_query($query_update,$connection) or die(mysql_error());
}
Obviously there is some pseudocode in there so you will have to make some changes, and I'm not completely sure it works, but that's really close to what works for me. What it does is counts the number of results for the query, and if there aren't any results ($num_rows_find < 1), then it inserts the information, otherwise it updates the information for the given ID.
Now that I think about it, I'm pretty sure this isn't the most efficient way to do things because there is a COUNT function in mysql that may save some time by avoiding calling mysql_num_rows and also avoiding the if statement, but I'm not sure how important efficiency is for you. I also don't really know much about COUNT so I can't help you there.