$ok = false;
 if (!array_key_exists($i, $new_username) || empty($new_username[$i]) || !array_key_exists($i, $new_name) || empty($new_name[$i]) || !array_key_exists($i, $new_email) || empty($new_email[$i]) || !array_key_exists($i, $new_lastname) || empty($new_lastname[$i])) {
     continue;
 }
 $new_username[$i] = trim(strtolower($new_username[$i]));
 $new_name[$i] = trim($new_name[$i]);
 $new_email[$i] = trim($new_email[$i]);
 $new_lastname[$i] = trim($new_lastname[$i]);
 if (empty($new_username[$i]) || empty($new_name[$i]) || empty($new_email[$i]) || empty($new_lastname[$i])) {
     $messages[] = sprintf(__gettext("User addition %d failed: at least one field was blank. Username: %s, name: %s, email: %s"), $i + 1, $new_username[$i], $new_name[$i], $new_email[$i]);
     continue;
 }
 if (!validate_username($new_username[$i])) {
     $messages[] = sprintf(__gettext("New username %d (%s) was invalid; usernames must contain letters and numbers only, cannot be blank, and must be between 3 and 12 characters in length."), $i + 1, $new_username[$i]);
     continue;
 } elseif (!username_is_available($new_username[$i])) {
     $messages[] = sprintf(__gettext("User addition %d failed: username %s is already in use."), $i + 1, $new_username[$i]);
     continue;
 }
 if (!validate_email($new_email[$i])) {
     $messages[] = sprintf(__gettext("User addition %d failed: email address %s appears to be invalid."), $i + 1, $new_email[$i]);
     continue;
 } elseif (record_exists('users', 'email', $new_lastname[$i])) {
     $messages[] = sprintf(__gettext("User addition %d failed: email address %s appears to be invalid."), $i + 1, $new_lastname[$i]);
     continue;
 }
 $password = "";
 // reset $j
 $j = 0;
 // add random characters to $password until $length is reached
 while ($j < 8) {
        }
    }
} else {
    // process the signup form.
    $u->username = optional_param('username');
    $u->password1 = optional_param('password1');
    $u->password2 = optional_param('password2');
    $u->email = optional_param('email');
    $u->name = optional_param('name');
    $mode = optional_param('mode');
    $messages = array();
    if ($mode == 'join') {
        // validate
        if (!validate_username($u->username)) {
            $messages[] = __gettext("Error! Your username must contain letters and numbers only, cannot be blank, and must be between 3 and 12 characters in length.");
        } elseif (!username_is_available(strtolower($u->username))) {
            $messages[] = __gettext("The username '{$username}' is already taken by another user. You will need to pick a different one.");
        }
        if (!validate_password($u->password1, $u->password2)) {
            $messages[] = __gettext("Error! Invalid password. Your passwords must match and be between 6 and 16 characters in length.");
        }
        if (empty($u->name)) {
            $messages[] = __gettext("Error! You must enter your fullname");
        }
        if (empty($messages)) {
            // we are good to go!
            $u->password = md5($u->password1);
            $ident = insert_record('users', $u);
        }
    } elseif ($mode == 'login') {
        $alias = $USER->alias;
     break;
 }
 if (empty($mail)) {
     $messages[] = __gettext('You must provide an email.');
     break;
 }
 $mail = strtolower($mail);
 if (record_exists('users', 'email', $mail)) {
     $messages[] = __gettext("The email '{$mail}' is already taken by another user. You will need to pick a different one.");
     break;
 }
 if (!validate_username($username)) {
     $messages[] = __gettext("Your username must contain letters and numbers only, cannot be blank, and must be between 3 and 12 characters in length.");
     break;
 }
 if (!username_is_available($username)) {
     $messages[] = __gettext("The username '{$username}' is already taken by another user. You will need to pick a different one.");
     break;
 }
 if ($password1 != $password2 || strlen($password1) < 6 || strlen($password2) > 16) {
     $messages[] = __gettext("Invalid password. Your passwords must match and be between 6 and 16 characters in length.");
     break;
 }
 /*if (!validate_password($password1, $password2)) {
       $messages[] = __gettext("Invalid password. Your passwords must match and be between 6 and 16 characters in length.");
       break;
   }*/
 //Se comentó porque no hacia la comparación entre la contraseña y la verificación de la contraseña
 if (empty($accept)) {
     $messages[] = __gettext("You must accept the Terms and Conditios to join.");
     break;