martynball
New Member
- Messages
- 60
- Reaction score
- 0
- Points
- 0
Any idea why the ip_s button won't delete all posts with that IP and add the IP to the other table?
ban.php
PHP:
<body>
<p style="color:#CCCCCC; font-family:Calibri; font-size:36px;" align="center">Administrator Tools</p>
<?php include "../scripts/db-connect.php"; ?>
<?php include "../scripts/delete.php"; ?>
<?php include "../scripts/ban.php"; ?>
<div style="overflow:scroll; height:50%; width:50%; overflow-x:hidden; margin:0 auto; background-color:#161616;">
<?php
//Get data...
$result = mysql_query("
SELECT * from commentTable
ORDER BY date DESC
");
while ($row = mysql_fetch_array($result))
{
$id=$row["ID"];
$name=$row["NAME"];
$message=$row["MESSAGE"];
$email=$row["EMAIL"];
$today= $row["DATE"];
$ip=$row["IP"];
//Display results
echo "<table class=\"comment-table\">";
echo "<tr>";
echo "<td class=\"comment-name\">Posted by: $name<div class=\"comments-date\">$today</div></td>";
echo "</tr>";
echo "<tr>";
echo "<td><p class=\"comment-message\"/>$message</p>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"comment-id\">ID: $id";
echo "<form method=\"post\" class=\"del-form\"><input name=\"id\" id=\"id\" type=\"hidden\" value=\"$id\"><input type=\"image\" src=\"../images/del.png\"></form></td>";
echo "</tr>";
echo "</table>";
echo "<center><form method=\"post\" class=\"ban-ip-f\"><input name=\"ip_s\" id=\"ip_s\" type=\"hidden\" value=\"$ip\"><input type=\"button\" class=\"ban-ip\" value=\"$ip\"></form></center>";
echo "<br />";
}
?>
</div>
</body>
</html>
ban.php
PHP:
<?php
if (isset($_POST['ip_s'])) {
$ip = mysql_real_escape_string($_POST['ip']);
$statement = "DELETE FROM commentTable WHERE IP='$ip'";
$result = mysql_query ($statement);
echo "<center><div class=\"deleted\">Banned and deleted all comments from $ip.</div></center>";
}
// BAN IP ADDRESS -----------------------------------------------
// Make varibles
$ip = mysql_real_escape_string($_POST['ip']);
if (isset($_POST['ip_s'])) {
// Insert data
$query="INSERT INTO banList (IP) VALUES ('".$ip."')";
$result = mysql_query ($query);
}
else {
echo "<p class=\"Error\"/>Error!</p>" .mysql_error();
}
?>