Rosst Posted August 14, 2006 Share Posted August 14, 2006 Please help, my ip banning script is causing a 500 error, here is the script:[code]<? include "site_top.php"; ?><?php require("config.php"); switch ($_GET[id]) {default:if(!isset($_POST[ban])){ // If the submit button hasnt been pressed echo "<form method='post'><b>IP Address:</b><br><input type='text' name='ip' maxlength='50'><br><b>Reason:</b> <br> <textarea name='reason' cols='30' rows='5'></textarea><br><input type='submit' name='ban' value='Ban IP'></form>";}if($_POST[ban]){ // If the submit button is pressed $ip = $_POST['ip']; //Get the name field $reason = $_POST['reason'];//Get the message filed if($ip == NULL || $reason == NULL){ // If either fields are left blank.. echo "A field was left blank, please go back and fix this."; //Echo a field was left blank. }else{ // If neither fields are blank... $postcmt = mysql_query("INSERT INTO `banned` (ip,reason,by) VALUES ('$ip','$reason','$logged[username]')"); //Insert the shout echo "The IP has been banned."; // Echo shout was posted } } $listbans = mysql_num_rows(mysql_query("SELECT * FROM banned ORDER BY id DESC"));if ($listbans < 1) {echo "<br />No bans have been made";}else {$bans = mysql_fetch_array(mysql_query("SELECT * FROM banned ORDER BY id DESC"));while ($b = $bans) {echo "<br />IP: $b[ip]<br />Reason: $b[reason]<br />By: $b[by]-----<a href=\"ipban.php?id=delete&ip=$b[ip]\">DELETE</a><br />";}}break;case 'delete':if (!$_GET[ans] && $_GET[ip]) {echo "Are you sure you want to delete this ban? <a href=\"ipban.php?id=delete&ans=yes\">Yes</a> Or <a href=\"ipban.php?id=delete&ans=no\">No</a>?";}elseif ($_GET[ans] == no && $_GET[ip]) {echo "You desided to keep the ban";}elseif ($_GET[ans] == yes && $_GET[ip]) {echo "Deleting ban...........";$delete = mysql_query("DELETE FROM banned WHERE ip = '$_GET[ip]'");echo "Ban deleted!!";}else {echo "You have reached a invalid page";}break;}?><? include "site_bot.php"; ?>[/code] Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 14, 2006 Share Posted August 14, 2006 The best way(that I know of) to set up a switch statment is like this.[code]<?phpinclude("whatever.php");function showpage($page) { switch ($page) { case "case 1": //some code here break; case "case 2": break; default: //your default code goes here }}showpage($_GET['page']);//you need this to execute your code?>[/code]Now you can link to this like this [b]whatever.php?page=case1[/b] Quote Link to comment Share on other sites More sharing options...
Rosst Posted August 14, 2006 Author Share Posted August 14, 2006 I don't care the best way to do a switch statment, can you help me or not Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 14, 2006 Share Posted August 14, 2006 [quote author=Rosst link=topic=104163.msg415304#msg415304 date=1155540250]I don't care the best way to do a switch statment, can you help me or not[/quote]With an attitude like that I most certainly will not and I doubt that anyone else will ether. Quote Link to comment 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.