Hi, I'm working on a site that allows users to connect with each other. User can search, find friend, and then request a connection. It works but if user request a second time it duplicates the row in table. I only want INSERT if does not exists.
Here is code.
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO mystuff.contact(user_id, user_url, rec_id, contact_id) VALUES(%s, %s, %s, %s)",
GetSQLValueString($_POST['hiddenField2'], "int"),
GetSQLValueString($_POST['hiddenField'], "text"),
GetSQLValueString($_POST['hiddenField3'], "text"),
GetSQLValueString($_POST['hiddenField4'], "text"),
GetSQLValueString($_POST['hiddenField5'], "text"),
GetSQLValueString($_POST['contact_id'], "int"));
mysql_select_db($database_connAdmin, $connAdmin);
$Result1 = mysql_query($insertSQL, $connAdmin) or die(mysql_error());
Only thing that really matters here is user_id and rec_id, which is other users user_id.
Thanks