Jump to content

[SOLVED] Refresh the page?


Lamez

Recommended Posts

well I could use sessions, they are all on the same page. I thought there could be a better way to do this.

 

<?php
ob_start();
$path = "../../";
$title = "Ban Users";
$rank = "yes";
include ($path."main/include/cons/head.php");
if($session->logged_in){
  if($session->isAdmin()){

  $ban = mysql_query("SELECT `username` FROM `users` WHERE `ban` = '0' and `userlevel` = '1'");
  $un = mysql_query("SELECT `username` FROM `users` WHERE `ban` = '1'");
  if (isset($_POST['ban'])){
    if (isset($_POST['user'])){
  $user = $_POST['user'];
  mysql_query("UPDATE `users` SET `ban`='1' WHERE `username`='$user'")or die(mysql_error());
  $message = $user." has been banned";
}
  }
  if (isset($_POST['un_ban'])){
    if (isset($_POST['ban_user'])){
  $banuser = $_POST['ban_user'];
  mysql_query("UPDATE `users` SET `ban`='0' WHERE `username`='$banuser'")or die(mysql_error());
  $message = $banuser." has been unbanned";
}
  }
?>  
<p class="header">Ban Users</p>
<p class="maintext">
<?php echo $message; ?>
<br />
<form id="ban" name="ban" method="post" action="">
  <table width="100%" border="0">
    <tr>
      <td width="7%">Users List</td>
      <td width="13%"><label>
        <select name="user" id="user">
        <?php
	 while($row = mysql_fetch_array($ban)){
           echo '<option value="'.$row['username'].'">'.$row['username'].'</option>';
         }
	?>
        </select>
      </label></td>
      <td width="80%"><label>
        <input type="submit" name="ban" id="ban" value="Ban User" />
      </label></td>
    </tr>
  </table>
</form>
<br />

<form id="unban" name="unban" method="post" action="">
  <table width="100%" border="0">
    <tr>
      <td width="7%">Users List</td>
      <td width="13%"><label>
        <select name="ban_user" id="ban_user">
        <?php
	 while($row = mysql_fetch_array($un)){
           echo '<option value="'.$row['username'].'">'.$row['username'].'</option>';
         }
	?>
        </select>
      </label></td>
      <td width="80%"><label>
        <input type="submit" name="un_ban" id="un_ban" value="unBan User" />
      </label></td>
    </tr>
  </table>
</form>
</p>
<?php
  }else{
  header('Location: '.$path.'index.php');
  }
}else{
header('Location: '.$path.'index.php');
}
include ($path."main/include/cons/foot.php");
?>

thanks for suggesting sessions variables, I got it to work just fine now.

 

<?php
ob_start();
$path = "../../";
$title = "Ban Users";
$rank = "yes";
include ($path."main/include/cons/head.php");
if($session->logged_in){
  if($session->isAdmin()){

  $ban = mysql_query("SELECT `username` FROM `users` WHERE `ban` = '0' and `userlevel` = '1'");
  $un = mysql_query("SELECT `username` FROM `users` WHERE `ban` = '1'");
  if (isset($_POST['ban'])){
    if (isset($_POST['user'])){
  $user = $_POST['user'];
  mysql_query("UPDATE `users` SET `ban`='1' WHERE `username`='$user'")or die(mysql_error());
  $_SESSION['message'] = $user." has been banned";
  header('Location: ban_us.php');
}
  }
  if (isset($_POST['un_ban'])){
    if (isset($_POST['ban_user'])){
  $banuser = $_POST['ban_user'];
  mysql_query("UPDATE `users` SET `ban`='0' WHERE `username`='$banuser'")or die(mysql_error());
  $_SESSION['message'] = $banuser." has been unbanned";
  header('Location: ban_us.php');
}
  }
?>  
<p class="header">Ban Users</p>
<p class="maintext">
<?php echo $_SESSION['message']; ?>
<br />
<form id="ban" name="ban" method="post" action="">
  <table width="100%" border="0">
    <tr>
      <td width="7%">UnBanned</td>
      <td width="13%"><label>
        <select name="user" id="user">
        <?php
	 while($row = mysql_fetch_array($ban)){
           echo '<option value="'.$row['username'].'">'.$row['username'].'</option>';
         }
	?>
        </select>
      </label></td>
      <td width="80%"><label>
        <input type="submit" name="ban" id="ban" value="Ban User" />
      </label></td>
    </tr>
  </table>
</form>
<br />

<form id="unban" name="unban" method="post" action="">
  <table width="100%" border="0">
    <tr>
      <td width="7%">Banned</td>
      <td width="13%"><label>
        <select name="ban_user" id="ban_user">
        <?php
	 while($row = mysql_fetch_array($un)){
           echo '<option value="'.$row['username'].'">'.$row['username'].'</option>';
         }
	?>
        </select>
      </label></td>
      <td width="80%"><label>
        <input type="submit" name="un_ban" id="un_ban" value="unBan User" />
      </label></td>
    </tr>
  </table>
</form>
</p>
<?php
  }else{
  header('Location: '.$path.'index.php');
  }
}else{
header('Location: '.$path.'index.php');
}
include ($path."main/include/cons/foot.php");
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.