I have a form with just 1 button that puts in 2 values, Uname, pulled from a cookie, and friend_uname pulled from the address where index.php?user=usernamegoeshere
How do i check the DB for an existing value and if it exists not add the new information. But if there is no entry with those values, it puts it in. Thanks.
INSERT only if no value exists
Moderator: General Moderators
Would the constraint work because each user can add eachother as a friend. Thus the Uname field can have unlimited entries as long as each one has a unique friend_uname and also friend_uname can appear unlimited times as long as it has a unique Uname with it.
I dont think i could do id's either because the ID field is auto_inc. Would there be a way to do it using the form inputs. Because the Add to Friends button is just a form with 2 hidden fields, is there a way to check the form values before submiting them. Like by doing a if $Uname == $row["Uname"] and $friend_uname == $row["friend_uname"] then exit else or something to that effect?
I dont think i could do id's either because the ID field is auto_inc. Would there be a way to do it using the form inputs. Because the Add to Friends button is just a form with 2 hidden fields, is there a way to check the form values before submiting them. Like by doing a if $Uname == $row["Uname"] and $friend_uname == $row["friend_uname"] then exit else or something to that effect?