Location: PHPKode > projects > DATA system > datasystem-0.8.7/html/u/delgroup.php
<?
/*
 *  delgroup.php
 *  Delete group
 *
 *  Changes:
 *  Nov.05,2003  Shinya Meguro
 *   - Here document is used.
 *   - Group id is not used option value.
 */

adminonly();

pageheader("main", "Delete a group");

if (GET) {

	// Get a list of groups
	$Groups = db_grouplist();

	$glist = "";
	foreach($Groups as $gname) {
		$glist .= "      <option value=\"$gname\">$gname</option>\n";
	}

	print <<<__EOD__
 <form method="post" action="delgroup.php">
  <h3>Delete a group</h3>
  <table>
   <tr>
    <td align="right" valign="top">Select group:</td>
    <td>
     <select name="gname">
      <option></option>
	$glist
     </select>
    </td>
   </tr>
   <tr>
    <td></td>
    <td><input type="submit" name="doSubmit" value="Delete group"></td>
   </tr>
  </table>
 </form>
__EOD__;


}
elseif (POST && ($params["doSubmit"] == "Delete group") )
{
	if (array_key_exists('gname',$params) && !($params['gname']=='')) {
		if (preg_match('/^([a-z]+[\w\d_]*)$/', trim($params['gname']), $matches)) {
			$gname = $matches[1];
		} else {
			errorfooter("Group name must be start a-z and can be use 'a' to 'z', number and under score(_).");
		}
	} else {
		errorfooter("Group name must be set.");
	}

	db_delgroup( $gname );

	setLocation("./listgroups.php");

}

pagefooter();
?>
Return current item: DATA system