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");
?>

Link to comment
Share on other sites

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");
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.