コード例 #1
0
ファイル: authorize.php プロジェクト: rohitatcu/aarp
session_start();
$admin_password = '******';
isset($_REQUEST['uname']) ? $uname = trim($_REQUEST['uname']) : ($uname = "");
isset($_REQUEST['pwd']) ? $pwd = trim($_REQUEST['pwd']) : ($pwd = "");
isset($_REQUEST['auth_pwd']) ? $auth_pwd = trim($_REQUEST['auth_pwd']) : ($auth_pwd = "");
//check incorrect input
if ($uname == Null || $pwd == Null || $auth_pwd == Null) {
    showAuthorizeForm();
    return;
}
//check admin password
if (md5($auth_pwd) != $admin_password) {
    printMsg('Incorrect admin password');
    return;
}
if (DBHandler::checkLoginExists($uname)) {
    printMsg("User " . $uname . " already exists");
    return;
}
createUser($uname, $pwd);
function createUser($uname, $pwd)
{
    $id = DBHandler::createUser($uname, $pwd);
    printMsg('Created ' . $uname . " successfully with id " . $id);
}
function printMsg($str)
{
    $_SESSION['msg'] = $str;
    header('Location: ' . 'msg.php');
    exit;
}