Location: PHPKode > projects > Gsys > admin/approve_users.php
<?PHP
//Filename : approve_users.php
//Description :  Form to list users awaiting approval and provide means to approve/deny them.
//Author :  darc
//Last modified :  2006.01.12

  include('../includes/auth.php');
  include_once('../includes/db.php');
  include_once('../includes/vars.php');

  if($_POST['submitted'] == "TRUE")
  {

//Need to add ability to check if both approve and deny were selected for same user... just in case our admin is stupid.
//Can be done in page with javascript, but that's gay.  Consider using radio boxes?

    if($_POST['ausernames'])
    foreach($_POST['ausernames'] as $user)
    {
      $sql = "UPDATE brothers SET status = 'active' WHERE username = '$user'";
      $result = mysql_query($sql,$connection) or die(mysql_error());
      $asuccess = "Member(s) successfully approved.";
    }

    if($_POST['dusernames'])
    foreach($_POST['dusernames'] as $user)
    {
      $sql = "UPDATE brothers SET status = 'denied' WHERE username = '$user'";
      $result = mysql_query($sql,$connection) or die(mysql_error());
      $dsuccess = "Member(s) successfully denied.";
    }
  }

  $sql = "SELECT * FROM brothers WHERE status = 'pending'";
  $result = mysql_query($sql,$connection) or die(mysql_error());

  $num = mysql_num_rows($result);
  if($num == 0)
    $nouser = "TRUE";
    
  $title = "Approve/Deny Users";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
  <title>
  <?php echo "".$chapter." :: " .$title. " :: " .$school.""; ?>
  </title>

  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" type="text/css" href="../includes/index.css" media="screen" />
</head>


<body class="body">

<br />
<table width="810" height="626" border="0" align="center" cellpadding="15">
  <tr>
    <td height="128" colspan="2"><img src="../images/eg_banner.gif" width="810" height="172"></td>
  </tr>
  <tr>
    <td width="27%" height="488" valign="top"> <?php include '../includes/nav.inc'; ?></td>
    <td width="53%" valign="top">
    <center><h2>Approve/Deny users</h2></center>
  <!-- FORM -->
   <?PHP
      echo "<span class=\"success\">$asuccess</span><br />";
      echo "<span class=\"success\">$dsuccess</span><br />";
     if($nouser == "TRUE")
      echo "<span class=\"error\">No users awaiting approval</span>\n";
     else
     {
       echo "<form method=\"post\" action=\"approve_users.php\">\n"
            ."<table width=\"100%\" border=\"1\" cellpadding=\"1\">\n"
            ."<tr>\n"
            ."<th>Username</th>\n"
            ."<th>Name</th>\n"
            ."<th>E-Mail</th>\n"
            ."<th>Approve</th>\n"
            ."<th>Deny</th>\n"
            ."</tr>\n";

            //start loop to display results
            while ($row =mysql_fetch_array($result))
            {
                        $un = $row['username'];
                        $name = $row['l_name']. ", " .$row['f_name'];
                        $email = $row['email'];
        echo "<tr>\n"
        ."<td>$un</td>"
        ."<td>$name</td>"
        ."<td>$email</td>"
        ."<td><input type=\"checkbox\" value=\"$un\" name=\"ausernames[]\" /></td>"
        ."<td><input type=\"checkbox\" value=\"$un\" name=\"dusernames[]\" /></td>"
       ."</tr>";

            } //close loop

    echo "</table>\n"
    ."<p><input type=\"hidden\" name=\"submitted\" value=\"TRUE\" />\n"
    ."<input type=\"submit\" name=\"submit\" value=\"Approve/Deny Users\" /></p>\n"
    ."</form>";
  }
    ?>
    </td>
  </tr>
</table>
<?PHP include ('../includes/footer.php'); ?>

Return current item: Gsys