cobusbo Posted January 10, 2015 Share Posted January 10, 2015 Hi, I've currently started to modify a chat script of mine to output a moderation panel but the moderation page seems empty(blank) every time I load it. What im trying to do is to take the ID part in my URL via the $_GET and look it up in my database table in the column named id, then select that specific row to be able to retrieve the StringyChat_ip and place it into another table to ban the IP and the second thing im trying to do is to be able to delete the specific row from my table. My Http link look something like http://imagecrab.freeserver.me/ag/ban.php?id=159 and my ban.php page where I want to lookup the 159 part and do the banning etc looks like <? include("admin_code_header.php"); if ($_POST["DeletePost"]) { $id = $_POST['id']; $query = "DELETE FROM ".$dbTable." WHERE id='".$id."'"; mysql_query($query); echo "ID removed from system: ".$id; } if ($_POST["BanIP"]) { $IP_To_Add = $_POST["ip"]; $sql = "INSERT INTO ".$IPBanTable." (ip) VALUES (\"$IP_To_Add\")"; $result = mysql_query($sql); } $result = mysql_query("SELECT * FROM ".$dbTable." WHERE id='".$id."'",$db); while ($myrow = mysql_fetch_array($result)) { $msg = $myrow["StringyChat_message"]; $idm = $myrow["id"]; ?> <html> <form name="form<? echo $myrow["id"];?>" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input name="DeletePost" type="submit" id="DeletePost" value="Delete"> <input name="BanIP" type="submit" id="BanIP" value="Ban <? echo $myrow["StringyChat_ip"];?>"> </form> </html> <? } ?> Quote Link to comment https://forums.phpfreaks.com/topic/293792-lookup-data-and-modifying-data-into-database-help-needed/ Share on other sites More sharing options...
cobusbo Posted January 10, 2015 Author Share Posted January 10, 2015 Hi, I've currently started to modify a chat script of mine to output a moderation panel but the moderation page seems empty(blank) every time I load it. What im trying to do is to take the ID part in my URL via the $_GET and look it up in my database table in the column named id, then select that specific row to be able to retrieve the StringyChat_ip and place it into another table to ban the IP and the second thing im trying to do is to be able to delete the specific row from my table. My Http link look something like and my ban.php page where I want to lookup the 159 part and do the banning etc looks like <? include("admin_code_header.php"); if ($_POST["DeletePost"]) { $id = $_POST['id']; $query = "DELETE FROM ".$dbTable." WHERE id='".$id."'"; mysql_query($query); echo "ID removed from system: ".$id; } if ($_POST["BanIP"]) { $IP_To_Add = $_POST["ip"]; $sql = "INSERT INTO ".$IPBanTable." (ip) VALUES (\"$IP_To_Add\")"; $result = mysql_query($sql); } $result = mysql_query("SELECT * FROM ".$dbTable." WHERE id='".$id."'",$db); while ($myrow = mysql_fetch_array($result)) { $msg = $myrow["StringyChat_message"]; $idm = $myrow["id"]; ?> <html> <form name="form<? echo $myrow["id"];?>" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input name="DeletePost" type="submit" id="DeletePost" value="Delete"> <input name="BanIP" type="submit" id="BanIP" value="Ban <? echo $myrow["StringyChat_ip"];?>"> </form> </html> <? } ?> Ok so I spend some more time with the script and made a few more changes. The options display now but nothing happens when I try to execute them. First of all I added the ip to my URL as well http://imagecrab.freeserver.me/ag/ban.php?id=159&ip=cobusbo and made a few changes in my ban.php file like the $_POST changed to $_GET and my form action need to be changed not sure to what. here is my ban.php file <? include("admin_code_header.php"); if ($_POST["DeletePost"]) { $id = $_GET["id"]; $query = "DELETE FROM ".$dbTable." WHERE id='".$id."'"; mysql_query($query); echo "ID removed from system: ".$id; } if ($_POST["BanIP"]) { $IP_To_Add = $_GET["ip"]; $sql = "INSERT INTO ".$IPBanTable." (ip) VALUES (\"$IP_To_Add\")"; $result = mysql_query($sql); } ?> <html> <form name="form" method="post" action="ban.php"> <input name="DeletePost" type="submit" id="DeletePost" value="Delete"> <input name="BanIP" type="submit" id="BanIP" value="Ban <? echo $_GET['ip'];?>"> </form> </html> Quote Link to comment https://forums.phpfreaks.com/topic/293792-lookup-data-and-modifying-data-into-database-help-needed/#findComment-1502400 Share on other sites More sharing options...
Solution cobusbo Posted January 10, 2015 Author Solution Share Posted January 10, 2015 Ok so I spend some more time with the script and made a few more changes. The options display now but nothing happens when I try to execute them. First of all I added the ip to my URL as well and made a few changes in my ban.php file like the $_POST changed to $_GET and my form action need to be changed not sure to what. here is my ban.php file <? include("admin_code_header.php"); if ($_POST["DeletePost"]) { $id = $_GET["id"]; $query = "DELETE FROM ".$dbTable." WHERE id='".$id."'"; mysql_query($query); echo "ID removed from system: ".$id; } if ($_POST["BanIP"]) { $IP_To_Add = $_GET["ip"]; $sql = "INSERT INTO ".$IPBanTable." (ip) VALUES (\"$IP_To_Add\")"; $result = mysql_query($sql); } ?> <html> <form name="form" method="post" action="ban.php"> <input name="DeletePost" type="submit" id="DeletePost" value="Delete"> <input name="BanIP" type="submit" id="BanIP" value="Ban <? echo $_GET['ip'];?>"> </form> </html> Ok so I fixed my script yay <? $conn = mysql_connect('*********','************','*********') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('*********',$conn) or trigger_error("SQL", E_USER_ERROR); if ($_POST["DeletePost"]) { $id = $HTTP_GET_VARS["id"]; $query = "DELETE FROM StringyChat WHERE id ='".$id."'"; mysql_query($query); echo "ID removed from system: ".$id; } if ($_POST["BanIP"]) { $IP_To_Add = $HTTP_GET_VARS["ip"]; $sql = "INSERT INTO StringyChat_IPBan (ip) VALUES (\"$IP_To_Add\")"; $result = mysql_query($sql); } if ($_POST["Unban"]) { $IP_To_Remove = $HTTP_GET_VARS['ip']; $query = "DELETE FROM StringyChat_IPBan WHERE ip ='".$IP_To_Remove."'"; mysql_query($query); echo "IP Removed from ban list: ".$IP_To_Remove; } ?> <html> <form name="form" method="post" action="<? echo $_SERVER['REQUEST_URI']; ?>"> <br> <input name="DeletePost" type="submit" id="DeletePost" value="Delete Message"><br><br> <input name="BanIP" type="submit" id="BanIP" value="Ban <? echo $HTTP_GET_VARS['ip'];?>"> <br><br> <input name="Unban" type="submit" id="Unban" value="Unban <? echo $HTTP_GET_VARS['ip'];?>"> </form> <br><br> <a href="page.php">Back</a> </html> Quote Link to comment https://forums.phpfreaks.com/topic/293792-lookup-data-and-modifying-data-into-database-help-needed/#findComment-1502430 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.