dean7 Posted August 25, 2009 Share Posted August 25, 2009 Hi all i have a ban script for my website but there is some kind of problem, here the script <?php include('config.php'); include('style.css'); include('functions.php'); session_start(); $username=$_SESSION['username']; $fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'")); $level=$fetch->level; if($level > "owner"){ $ban=$_POST['ban_username']; $time=$_POST['time']; $reason=$_POST['reason']; $type=$ban; if(!$ban){ }else{ mysql_query("UPDATE users SET status='Banned' WHERE username='$ban'"); mysql_query("INSERT INTO `ban` (`id`, `username`, `by`, `type`, `reason`, `length`) VALUES ('', '$ban', '$username', '$type', '$reason', '$time')"); mysql_query("INSERT INTO `log` ( `id` , `by` , `action` , `level` ) VALUES ('', '$username', 'Banned $ban_username for reason $ban_reason', '$userlevel')"); echo "You banned $ban."; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=ban.php\">"; } } ?> <style type="text/css"> <!-- body,td,th { color: #990000; } body { background-color: #999999; } --> </style><form name="form1" method="post" action=""> <table width="67%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="<?php echo "$td_border"; ?>" bgcolor="<?php echo "$td_bg"; ?>"> <tr> <td height=22 background="<?php echo"$gradient"; ?>"><center class="TableHeading"> <strong>Ban a user</strong> </center></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="3" cellpadding="0"> <tr> <td width="50%">Username</td> <td width="50%"><input name="ban_username" type="text" id="ban_username"></td> </tr> <tr> <td>Length(Levae blank for permanent ban).</td> <td><input name="time" type="text" id="time"> Hours</td> </tr> <tr> <td>Reason</td> <td><textarea name="ban_reason" cols="40" rows="7" id="ban_reason"></textarea></td> </tr> <tr> <td> </td> <td><input name="Ban" type="submit" id="Ban" value="Ban this user"></td> </tr> </table></td> </tr> </table> </form> <p><br> <br> </p> </body> </html> When you put the in info in then click 'ban this user' nothing happends anyone know why? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/171851-ban-script/ Share on other sites More sharing options...
mikesta707 Posted August 25, 2009 Share Posted August 25, 2009 AND I SWING MY MIGHTY BANHAMMA um.. Well what is supposed to happen? and what do you mean by nothing happens? Blank page? table doesn't update? try adding or die(mysql_error()); to the end of all your queries to see if you get an error Quote Link to comment https://forums.phpfreaks.com/topic/171851-ban-script/#findComment-906154 Share on other sites More sharing options...
ignace Posted August 25, 2009 Share Posted August 25, 2009 if($level > "owner"){ is the same as if ($level > 0){ What does $level contain? If $level contains a string (altough not entirely sure it's possible php performs an internal strcmp() but then again you'll get unexpected results as member > owner thus member may ban other members) you'll get if (0 > 0) { if(!$ban){ }else{ is the same as if ($ban){ Quote Link to comment https://forums.phpfreaks.com/topic/171851-ban-script/#findComment-906160 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.