* controll logical code here
 */
if (isset($_POST['username']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['password'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $passwordConfirm = $_POST['passwordconfirm'];
    if ($password == $passwordConfirm) {
        $rs = $config[DAOIMPL]->getUserByName($username);
        $arr = mysql_fetch_array($rs);
        if ($arr) {
            //check if the username exist
            $errorMsg = '用户添加失败!此用户名已存在!';
            unset($_POST['username']);
        } else {
            //add user
            $newUser = array('username' => $username, 'password' => generateUserPassword($password));
            $rs = $config[DAOIMPL]->addUser($newUser);
            $successMsg = '用户添加成功!';
        }
    } else {
        $errorMsg = '两次输入的密码不一致!';
    }
}
/**----------------
 * config title, description, keywords
*/
$pageTitle = '添加用户';
$pageDescription = '';
$pageKeywords = '';
/**----------------
 * render views
 * controller: login page
 * create by lane
 * @2012-01-01
 */
echo "用户名或者密码输入错误";
$pageName = 'login';
$needDb = true;
//enable db
/**----------------
 * include common files
 */
$incPath = dirname(__FILE__);
require_once "{$incPath}/inc/init.php";
/**----------------
 * controll logical code here
 */
//user login
if (isset($_POST['username']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['password'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $rs = $config[DAOIMPL]->getUserByName($username);
    $arr = mysql_fetch_array($rs);
    if ($arr && $arr['password'] == generateUserPassword($password)) {
        $_SESSION[SESSIONUSER] = $username;
        header("Location: index.php");
        exit(0);
    } else {
        header("Location: login.html");
        exit(0);
    }
}
<?php

$includePath = dirname(__FILE__);
require_once "{$includePath}/../inc/constant.php";
require_once "{$includePath}/../inc/config.php";
require_once "{$includePath}/../inc/util.php";
header('content-type: text/html; charset=utf-8');
echo "您配置的用户密码是:{$config[SUPERUSERPASSWORD]}\n";
echo "加密之后的密码是:" . generateUserPassword($config[SUPERUSERPASSWORD]) . "\n";
echo "请将新的加密之后的密码更新到您的数据库,替换原有超级用户的密码!\n";