In my web application I have 2 buttons: one is "like", the other one is "dislike".
Users can't like their own profile.
I am looking for now a bit of code so that if a database check shows there is already a row for the user who wants to like or dislike that profile a message comes up: "You have already liked this user" or "You have already disliked this user"
<? if ($_POST['like']){
if(strtolower($view) == strtolower($fetchAccount['UserName'])){
echo "You cannot Like yourself!<br /><br/>";
} else {
mysql_query("INSERT INTO `ProfileLikes` (`id`, `Profile`, `Rated`,
`LikedDisliked`, `Date`) VALUES ('', '{$fetchUser['UserName']}',
'{$fetchAccount['UserName']}', 'Liked', '$time')");
echo "You Liked {$fetchUser['UserName']}!<br /><br />";
}
}
if ($_POST['Dislike']){
if(strtolower($view) == strtolower($fetchAccount['UserName'])){
echo "You cannot DisLike yourself!<br /><br />";
} else {
mysql_query("INSERT INTO `ProfileLikes` (`id`, `Profile`, `Rated`,
`LikedDisliked`, `Date`) VALUES ('', '{$fetchUser['UserName']}',
'{$fetchAccount['UserName']}', 'Disliked', '$time')");
echo "You DisLiked {$fetchUser['UserName']}!<br /><br />";
}
}
?>
Can anyone help please? Thanks in advance. :)