echo "{$Translation['error:']} {$Translation['Wrong password']}";
        echo "<script>\$\$('label[for=\"old-password\"]')[0].pulsate({ pulses: 10, duration: 4 }); \$('old-password').activate();</script>";
        exit;
    }
    if (strlen($newPassword) < 4) {
        echo "{$Translation['error:']} {$Translation['password invalid']}";
        echo "<script>\$\$('label[for=\"new-password\"]')[0].pulsate({ pulses: 10, duration: 4 }); \$('new-password').activate();</script>";
        exit;
    }
    /* update password */
    $updateDT = date($adminConfig['PHPDateTimeFormat']);
    sql("UPDATE `membership_users` set `passMD5`='" . md5($newPassword) . "', `comments`=CONCAT_WS('\\n', comments, 'member changed his password on {$updateDT} from IP address {$mi[IP]}') WHERE memberID='{$mi['username']}'", $eo);
    // hook: member_activity
    if (function_exists('member_activity')) {
        $args = array();
        member_activity($mi, 'password', $args);
    }
    exit;
}
/* get profile info */
/* 
	$mi already contains the profile info, as documented at: 
	http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo

	custom field names are stored in $adminConfig['custom1'] to $adminConfig['custom4']
*/
$permissions = array();
$userTables = getTableList();
if (is_array($userTables)) {
    foreach ($userTables as $tn => $tc) {
        $permissions[$tn] = getTablePermissions($tn);
        exit;
    }
    // save member data
    $needsApproval = sqlValue("select needsApproval from membership_groups where groupID='{$groupID}'");
    sql("INSERT INTO `membership_users` set memberID='{$memberID}', passMD5='" . md5($password) . "', email='{$email}', signupDate='" . @date('Y-m-d') . "', groupID='{$groupID}', isBanned='0', isApproved='" . ($needsApproval == 1 ? '0' : '1') . "', custom1='{$custom1}', custom2='{$custom2}', custom3='{$custom3}', custom4='{$custom4}', comments='member signed up through the registration form.'", $eo);
    // admin mail notification
    /* ---- application name as provided in AppGini is used here ---- */
    if ($adminConfig['notifyAdminNewMembers'] == 2 && !$needsApproval) {
        @mail($adminConfig['senderEmail'], '[real estate] New member signup', "A new member has signed up for real estate.\n\nMember name: {$memberID}\nMember group: " . sqlValue("select name from membership_groups where groupID='{$groupID}'") . "\nMember email: {$email}\nIP address: {$_SERVER['REMOTE_ADDR']}\nCustom fields:\n" . ($adminConfig['custom1'] ? "{$adminConfig['custom1']}: {$custom1}\n" : '') . ($adminConfig['custom2'] ? "{$adminConfig['custom2']}: {$custom2}\n" : '') . ($adminConfig['custom3'] ? "{$adminConfig['custom3']}: {$custom3}\n" : '') . ($adminConfig['custom4'] ? "{$adminConfig['custom4']}: {$custom4}\n" : ''), "From: {$adminConfig['senderEmail']}\r\n\r\n");
    } elseif ($adminConfig['notifyAdminNewMembers'] >= 1 && $needsApproval) {
        @mail($adminConfig['senderEmail'], '[real estate] New member awaiting approval', "A new member has signed up for real estate.\n\nMember name: {$memberID}\nMember group: " . sqlValue("select name from membership_groups where groupID='{$groupID}'") . "\nMember email: {$email}\nIP address: {$_SERVER['REMOTE_ADDR']}\nCustom fields:\n" . ($adminConfig['custom1'] ? "{$adminConfig['custom1']}: {$custom1}\n" : '') . ($adminConfig['custom2'] ? "{$adminConfig['custom2']}: {$custom2}\n" : '') . ($adminConfig['custom3'] ? "{$adminConfig['custom3']}: {$custom3}\n" : '') . ($adminConfig['custom4'] ? "{$adminConfig['custom4']}: {$custom4}\n" : ''), "From: {$adminConfig['senderEmail']}\r\n\r\n");
    }
    // hook: member_activity
    if (function_exists('member_activity')) {
        $args = array();
        member_activity(getMemberInfo($memberID), $needsApproval ? 'pending' : 'automatic', $args);
    }
    // redirect to thanks page
    $redirect = $needsApproval ? '' : '?redir=1';
    redirect("membership_thankyou.php{$redirect}");
    exit;
}
// drop-down of groups allowing self-signup
$groupsDropDown = preg_replace('/<option.*?value="".*?><\\/option>/i', '', htmlSQLSelect('groupID', "select groupID, concat(name, if(needsApproval=1, ' *', ' ')) from membership_groups where allowSignup=1 order by name", $cg == 1 ? sqlValue("select groupID from membership_groups where allowSignup=1 order by name limit 1") : 0));
$groupsDropDown = str_replace('<select ', '<select class="form-control" ', $groupsDropDown);
?>

<?php 
if (!$noSignup) {
    ?>
	<div class="row">