• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

AAC gesior - get Recovery Key

Fortera Global

Intermediate OT User
Joined
Nov 20, 2015
Messages
1,181
Solutions
2
Reaction score
117
I'm trying one code to: player will need write recovery key in some field for continue..
something like this:

Edited:

PHP:
$main_content .= '<TD WIDTH=10%><input required name="key" type=text min="2" max="10"></TD>';

$rec_key = trim($_REQUEST['key']);
    
        $temp_account = new Account();
        $account_key = $temp_account->getCustomField('key');
    
        if(empty($account_key))
                {
                    $main_content .= 'Administrator, recovery key is empty';
                }else
                {
                    if(!$account_key == $rec_key)
                        {
            $main_content .= 'Administrator, recovery key could not be found';
                }else
                {
        $temp_account->find($config['site']['charactertrade']['secret_account_name']);
        if (!$temp_account->isLoaded())
        {
            $main_content .= 'Administrator, secret account could not be found';
        }else
        {
            $main_content .= 'something here';
    }

  }
 
Last edited by a moderator:
Solution
Then you don't mean min and max, but minlength and maxlength in your input.

Like this:
Code:
<TD WIDTH=10%><input required name="key" type=text minlength="2" maxlength="10"></TD>

And to validate, you can do this, like this:
PHP:
if(!isset($_POST['key']) || empty($_POST['key'])) {
    // no recovery key sent or empty
}
else {
    $key = $_POST['key'];
    $len = strlen($key);
    if($len < 2 || $len > 10) {
        // recovery key too long, or too short
    }
    else {
        if($temp_account->getCustomField('key') != $key) {
            // key is not same on account
        }
        else {
            // all ok
        }
    }
}
Back
Top