登录页面,其中包含3个用于用户名的输入框每个框3个字符

问题描述

试图找到修改Joomla用户名登录的最佳方法我有根据位置内置在用户名中的帐户类型。 XXX-AT1-XXX,根据帐户类型,ACT可以从位置1、2或3移动。因此,我需要3个输入框来将用户名作为3个框,并加入XXX和XXX并删除ACT(因为仅需要访问内容)才能在数据库中为auth设置用户名,该用户名应为XXXXXX。我没有设计这个。我知道我永远不会选择它,但是他们想要帐户类型的可视状态,但不影响真实的用户名

我已将用户名拆分为id = username1 username2和username3。我将大部分时间删除用户名2,并加入用户名1和用户名3以建立用户名

提示此问题的最佳方法是什么,提交时发送正确的用户名,因此我不需要修改Joomla的后端功能。我需要生存更新。这是使用模板替代,因此它可以保留更新。它需要是jquery,但随后需要与ajax混淆。或者可以在用PHP提交之前完成。

谢谢!

 <?PHP
/**
 * @package     Joomla.Site
 * @subpackage  com_users
 *
 * @copyright   copyright (C) 2005 - 2014 Open Source Matters,Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

JHtml::_('behavior.keepalive');
JHtml::_('behavior.formvalidator');
?>
<div  <?PHP echo $this->pageclass_sfx?>">
    <?PHP if ($this->params->get('show_page_heading')) : ?>
    <div class="page-header">
        <h1>
            <?PHP echo $this->escape($this->params->get('page_heading')); ?>
        </h1>
    </div>
    <?PHP endif; ?>

    <?PHP if (($this->params->get('logindescription_show') == 1 && str_replace(' ','',$this->params->get('login_description')) != '') || $this->params->get('login_image') != '') : ?>
    <div class="login-description">
    <?PHP endif; ?>

        <?PHP if ($this->params->get('logindescription_show') == 1) : ?>
            <?PHP echo $this->params->get('login_description'); ?>
        <?PHP endif; ?>

        <?PHP if (($this->params->get('login_image') != '')) :?>
            <img src="<?PHP echo $this->escape($this->params->get('login_image')); ?>" class="login-image" alt="<?PHP echo JText::_('COM_USER_LOGIN_IMAGE_ALT')?>"/>
        <?PHP endif; ?>

    <?PHP if (($this->params->get('logindescription_show') == 1 && str_replace(' ',$this->params->get('login_description')) != '') || $this->params->get('login_image') != '') : ?>
    </div>
    <?PHP endif; ?>

    <form action="<?PHP echo JRoute::_('index.PHP?option=com_users&task=user.login'); ?>" method="post" class="form-validate form-horizontal">

        <fieldset class="well">
            <?PHP foreach ($this->form->getFieldset('credentials') as $field) : 
                switch($field->name) {
                    case 'username':
                        $inputClass = 'fa-user';
                        break;
                    case 'password':
                        $inputClass = 'fa-lock';
                        break;
                    default:
                        $inputClass = '';
                }
            ?>
                <?PHP if (!$field->hidden) : ?>
                    <div class="control-group">
                        <div class="control-label">
                            <i class="fa <?PHP echo $inputClass;?>"></i>
                            <?PHP echo $field->label; ?>
                        </div>
                        <div class="controls" style="display: flex;">
                             
<?PHP
// work on id username
$word = 'username';

// Test if string contains the word 
if(strpos($field->input,$word) !== false){
    $INPUT = str_replace('size="25"','maxlength="3" size="3"',$field->input);
  
    $username1 = $resstr = str_replace('id="username"','id="username1"',$INPUT);
    $username2 = $resstr = str_replace('id="username"','id="username2"',$INPUT);
    $username3 = $resstr = str_replace('id="username"','id="username3"',$INPUT);
    echo "$username1";
    echo "-";
    echo "$username2";
    echo "-";
    echo "$username3";
     
} else{
                            echo $field->input;
}
?>
                        </div>
                    </div>
                <?PHP endif; ?>
            <?PHP endforeach; ?>

            <?PHP $tfa = jpluginHelper::getPlugin('twofactorauth'); ?>

            <?PHP if (!is_null($tfa) && $tfa != array()): ?>
                <div class="control-group">
                    <div class="control-label">
                        <i class="fa fa-key"></i>
                        <?PHP echo $this->form->getField('secretkey')->label; ?>
                    </div>
                    <div class="controls">
                        <?PHP echo $this->form->getField('secretkey')->input; ?>
                    </div>
                </div>
            <?PHP endif; ?>

            <?PHP if (jpluginHelper::isEnabled('system','remember')) : ?>
            <div  class="control-group form-login-remember">
                <div class="control-label">
                    <i class="fa fa-save"></i> <label><?PHP echo JText::_('COM_USERS_LOGIN_REMEMBER_ME') ?></label>
                    <input id="remember" type="checkBox" name="remember" class="inputBox" value="yes"/>
                </div>
            </div>
            <?PHP endif; ?>

            <div class="controls">
                <button type="submit">
                    <?PHP echo JText::_('JLOGIN'); ?>
                </button>
            </div>

            <?PHP $return = $this->form->getValue('return',$this->params->get('login_redirect_url',$this->params->get('login_redirect_menuitem'))); ?>
            <input type="hidden" name="return" value="<?PHP echo base64_encode($return); ?>" />
            <?PHP echo JHtml::_('form.token'); ?>
        </fieldset>
    </form>
</div>
<div>
    <ul id="login_links">
        <li>
            <a href="<?PHP echo JRoute::_('index.PHP?option=com_users&view=reset'); ?>"><i class="fa fa-lock"></i> 
            <?PHP echo JText::_('COM_USERS_LOGIN_RESET'); ?></a>
        </li>
        <li>
            <a href="<?PHP echo JRoute::_('index.PHP?option=com_users&view=remind'); ?>"><i class="fa fa-user"></i> 
            <?PHP echo JText::_('COM_USERS_LOGIN_REMIND'); ?></a>
        </li>
        <?PHP
        $usersConfig = JComponentHelper::getParams('com_users');
        if ($usersConfig->get('allowUserRegistration')) : ?>
        <li>
            <a href="<?PHP echo JRoute::_('index.PHP?option=com_users&view=registration'); ?>"><i class="fa fa-plus"></i> 
                <?PHP echo JText::_('COM_USERS_LOGIN_REGISTER'); ?></a>
        </li>
        <?PHP endif; ?>
    </ul>
</div>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)