Location: PHPKode > projects > Simple Comments > comments/deletecomment.php
<? require("header.php"); ?>
<p align="center">
<?
require_once( 'config.php' );
$id=$_GET['id'];
$ipuser=getenv('REMOTE_ADDR');

mysql_connect($dbaddress,$dbuser,$dbpass);
@mysql_select_db($dbname) or die( "Unable to select database");
$querycheck="SELECT ip FROM comments WHERE id='$id'";
$resultcheck=mysql_query($querycheck);
$num=mysql_numrows($resultcheck);
if ($num==0) {
?>
<br>Comment not found.<br>
<br><br>
<a href="javascript: history.go(-1)">Back</a><br>
<?
} else {
$ip=mysql_result($resultcheck,0,"ip");
if ($ip==$ipuser) {

?>
<form method="post">
<p align="center">
Are you sure you want to delete this comment?
<input type="hidden" name="confirm" value="1">
<br>
<input type="Submit" value="Delete">
</form>
<?
$confirm=$_POST['confirm'];

if ($confirm==1) {


$query=" DELETE FROM comments WHERE id='$id'";
mysql_query($query);
echo "<br>Comment Deleted.<br>";

?>
<br><br>
<a href="javascript: history.go(-2)">Back</a><br>
<?
} else {

?>
<br><br>
<a href="javascript: history.go(-1)">Back</a><br>
<?
}

} else {
?>
<br>You are not allowed to delete this comment.<br>
<br><br>
<a href="javascript: history.go(-1)">Back</a><br>
<?
}
}
mysql_close();
Return current item: Simple Comments