actually i want the user delete their comment they dont want by their own id..if success delete,it will pop out deleted successfully..
now my problem is when the user try to delete the comment which are not their own,then it will pop out sorry,..... message..
but it still pop out deleted successfully..actually it not delete the comment..only the id and comid match just can delete..
i think the condition is ok ,but dont know why it failed to function..
can anyone help me to correct my error??thanks in advance..
Code: Select all
<?php
session_start();
require_once 'config.php';
$id=$_SESSION['id'];
$comid=$_REQUEST['comid'];
if ($id = $_SESSION['id'])
{
$query = 'DELETE FROM comment WHERE comid = '.$comid.' AND id ='.$id;
$result =mysql_query( $query);
echo"<script>alert(\"Deleted Successfully!\")</script><script>window.location='comment.php'</script>";
}
else {
echo"<script>alert(\"Sorry, You are not allowed to delete other users'comment!!\")</script><script>window.location='comment.php?id=$id'</script>";
}
?>