Location: PHPKode > projects > Philosopher'Stone Personal > pssp/useradd.php
<?php

include('setup.php');
allowed(1, 5);

$sc->register('users', array('class' => 'users', 'arguments' => '%db%', 'depends' => 'db'));
$u = $sc->users;

$fields = array(
    'userid' => array('name' => 'User ID', 'filter' => 'alpha', 'rules' => 'required', 'default' => $user['userid']),
    'username' => array('name' => 'User Name', 'filter' => 'name', 'rules' => 'required', 'default' => $user['username']),
    'password' => array('name' => 'Password', 'filter' => 'text', 'rules' => 'required|minlength[6]'),
	'confirm' => array('name' => 'Password Confirmation', 'filter' => 'text', 'rules' => 'required|match[password]'),
	'division' => array('name' => 'Division', 'filter' => 'integer', 'rules' => 'required|maxlength[2]'),
	'level' => array('name' => 'Level', 'filter' => 'integer', 'rules' => 'required|maxlength[2]'),
	'email' => array('name' => 'Email Address', 'filter' => 'email', 'default' => $user['email']));

$sc->register('validation', array('class' => 'validation', 'arguments' => '%fields%'));
$v = $sc->validation;

if (count($_POST) != 0)) {

	$errors = $v->validate();

	if ($errors == 0) {
		if (isset($_POST['add'])) {
			$userid = $u->add_user($_POST);
			if ($userid != 0) {
				smsg("User $userid successfully added.");
			}
			else {
				emsg("Unable to add user.");
				$errors++;
			}

		}
	}

	if ($errors == 0)
		redirect('userlst.php');
}

$meta['app_navs'] = $app_navs->get();
$meta['file_mtime'] = date('d F Y H:i:s', getlastmod());
$meta['mod_navs'] = array(
	array('url' => 'userlst.php', 'txt' => 'List Users')
);
$meta['focus_field'] = 'userid';
$meta['return_url'] = 'useradd.php';
$meta['app_title'] = 'Users';
$meta['page_title'] = 'Add User';
$meta['view_file'] = fullpath('view', 'useradd');

include 'generic.php';
Return current item: Philosopher'Stone Personal