I have this code that allows a user to only delete his own topics. It's working but in the case that the user is not the one who posted the topic, he is still getting the message: Topic has been deleted, whereas he should get: You didnt make this topic. The else statement isnt running.
if(isset($_SESSION['username']))
{
$uid = $_SESSION['uid'];
$id=$_GET['id'];
$check = mysql_query("SELECT * FROM topics WHERE id = '$id' AND topicCreator = '$uid'");
if($check){
$query1=mysql_query("delete FROM topics WHERE id='$id' AND topicCreator='$uid'");
echo "<p>Topic has been successfully deleted. <a href='index.php'>Click here to return to home page.</a>";
}
else{
echo "<p><b>ERROR: You didnt make this topic.";
}
}
I dont know why the else statement wont run.
$check is to see if the user who is logged in is the one who created the topic.
(PS: I'll switch to mysqli once this works.)