}
 $s3ql['where']['validation'] = $_POST['validation'];
 $s3ql['where']['notes'] = nl2br($_POST['notes']);
 $s3ql['format'] = 'html';
 #echo '<pre>';print_r($s3ql);
 $done = S3QLaction($s3ql);
 $msg = html2cell($done);
 #echo '<pre>';print_r($msg);
 #exit;
 #echo $done;
 #ereg('<error>(.*)</error>(.*)<(rule_id|message)>(.*)</(rule_id|message)>', $done, $s3qlout);
 #echo '<pre>';print_r($s3qlout);
 if ($msg[0]['error_code'] == '0') {
     $rule_id = $msg[0]['rule_id'];
     #echo '<pre>';print_r($users);exit;
     $message .= addUsers(compact('users', 'user_id', 'db', 'rule_id', 'element'));
 } else {
     $message .= $msg[0]['message'];
 }
 if ($message == '') {
     Header('Location: ' . $action['editrules']);
     exit;
 }
 $owner = find_user_loginID(array('account_id' => $user_id, 'db' => $db));
 $action_name = 'newrule';
 $action_value = 'Create';
 if ($resource_info != '') {
     $subject_input = $newrule['subject'];
 } else {
     $subject_input = '<input name="subject" style="background: lightyellow" value="' . $subject . '" size="10">';
 }
            $s3ql['where']['collection_id'] = $class_id;
            if ($_POST['notes'] != '') {
                $s3ql['where']['notes'] = nl2br($_POST['notes']);
            }
            $s3ql['format'] = 'html';
            $done = S3QLaction($s3ql);
            $msg = html2cell($done);
            #echo $done;
            #ereg('<item_id>([0-9]+)</item_id>', $done, $s3qlout);
            $instance_id = $msg[2]['item_id'];
            #preg_match('/[0-9]+/', $done, $instance_id);
            $item_id = $instance_id;
            if ($instance_id != '') {
                #now add the users
                $element = 'item';
                $message .= addUsers(compact('users', 'user_id', 'db', 'class_id', 'collection_id', 'element', 'item_id'));
                Header('Location: ' . $action['instanceform'] . '&item_id=' . $instance_id);
                exit;
            } else {
                echo $msg[2]['message'];
            }
        }
        #include all the javascript functions for the menus...
        include '../S3DBjavascript.php';
        #and the short menu for the resource script
        include '../action.header.php';
        #add the form for inserting instances
    }
}
//closes no permission
$new = 1;
require_once "../libraries/validation.php";
require_once "../table/admin.php";
$common = new common();
$sessionAdmin = $common->checkSession($adminSession, false);
if (empty($sessionAdmin)) {
    Res::sendInvalid($adminSessionOut);
}
$mysqli = new mysqli_functions();
$connection = $mysqli->connect();
if (is_bool($connection)) {
    Res::sendFailure($mysqli->message);
}
$req = new Req();
switch ($req->getCmd()) {
    case "addUsers":
        addUsers();
        break;
    default:
        Res::sendInvalid("invalidCmd:" . $req->getCmd());
}
$mysqli->disconnect();
function addUsers()
{
    global $req;
    global $connection;
    $req->hasParams("adminUName", "adminFName", "adminGender", "adminEMail", "adminPassword", "adminPhone");
    $adminUName = $req->getParam("adminUName");
    $adminFName = $req->getParam("adminFName");
    $adminGender = $req->getParam("adminGender");
    $adminEMail = $req->getParam("adminEMail");
    $adminPassword = $req->getParam("adminPassword");