Create an Account
Please correct the following:
=$oTpl->_($sErr)?>'Username', 'password' => 'Password', 'password_confirm' => 'Re-enter Password', 'secret_id' => 'Pick a reminder question', 'secret_answer' => 'Your answer' ); $aGenders = array('M' => 'Male', 'F' => 'Female', 'N' => 'Prefer not to say'); require_once('/afs/ece.cmu.edu/web/ece/htdocs/tools/msc-game/encryption-keys.php'); // Get the secret questions $sSql = 'SELECT secret_id, secret_name FROM gm_lkp_user_secret'; $aSecretQuestions = DBConn::getArray($sSql, 'secret_id', 'secret_name'); // Get the age group list $sSql = 'SELECT age_group_id, age_group_name FROM gm_lkp_user_age_group'; $aAgeGroups = DBConn::getArray($sSql, 'age_group_id', 'age_group_name'); $oErr = new ErrorCollector(); if (!empty($_POST['submit'])) { // Scrub input foreach ($_POST as $sKey => $sVal) { $_POST[$sKey] = getPost($sKey); } // Validate input // Check for missing inputs foreach ($aRequiredFields as $sRequiredField => $sRequiredFieldDescription) { if (empty($_POST[$sRequiredField])) { $oErr->add('"' . $sRequiredFieldDescription . '" must be provided.', true); } } // Check for duplicate user $sSql = 'SELECT COUNT(user_id) AS num_users FROM gm_user WHERE user_username = ?'; if (DBConn::getValue($sSql, 'num_users', array($_POST['username'])) >= 1) { $oErr->add('The username "' . $_POST['username'] . '" is already in use. Please select another one.', true); $_POST['username'] = null; } if ($_POST['password'] != $_POST['password_confirm']) { $oErr->add('The passwords provided do not match.', true); } else if (!empty($_POST['password']) && strlen($_POST['password']) < $iMinPasswordLength) { $oErr->add('The password provided was too short. Please use a password with at least ' . $iMinPasswordLength . ' characters.'); } else if (strpos($_POST['password'], ' ') !== false) { $oErr->add('Your password can not contain any spaces.', true); } if (!$oErr->hasError()) { // Create the account $sSql = 'INSERT INTO gm_user (user_username, user_password, secret_id, secret_answer, age_group_id, user_gender, date_registered) VALUES (?, AES_ENCRYPT(?, ?), !, AES_ENCRYPT(?, ?), ?, ?, !)'; if (DBConn::executeNonQuery($sSql, array($_POST['username'], $_POST['password'], AES_ENCRYPTION_KEY_PASSWORD, $_POST['secret_id'], $_POST['secret_answer'], AES_ENCRYPTION_KEY_SECRET, $_POST['age_group_id'], $_POST['gender'], 'CURDATE()'))) { $iUserId = DBConn::getLastInsertId(); doRedirect('registerComplete.html'); } else { $oErr->add('We were unable to save your information. Please try again, or email us for help.', true); } } } $sErr = $oErr->toString(); $oTpl = new Savant2_Common(); ?>