duan5731 2014-02-18 10:15
浏览 36

CodeIgniter获取用户名并从Model到View显示它

After a few testing here and there, I have finally found a way where I can get the registered username. But I still can't make it to display on the page. I am stuck at getting the value from Model to Controller.

Below are my codes:

Model (user_model):

public function create_user( $role, $insert_array = array() )
{
if( ! empty( $insert_array ) OR $this->validate() === TRUE )
            {
                ...

            // Verify transaction was successful
            if( $this->db->trans_status() !== FALSE )
            {
                // Load var to confirm user inserted into database
                $this->load->vars( array( 'user_created' => 1 ) );
                $reg_username = $user_data['user_name'];
            }

            return TRUE;
        }
return FALSE;
    }

View:

if( isset( $validation_passed ) && $reg_mode == 1 )
    {

        echo '
            <div class="feedback confirmation">
                <p>
                    Thank you for registering. Your new username is :  You may now ' . secure_anchor('user', 'login') . '.
                </p>
            </div>
        ';
    }

Controller:

$this->load->model('user_model');
$this->user_model->create_user( 'customer', array() );

What and how should I do it?

Appreciate if you guys can help me out on this. Thanks in advance.

  • 写回答

2条回答 默认 最新

  • douqiao7958 2014-02-18 10:17
    关注

    You are not passing any arguments to your function when calling in view

    Instead of this

    echo $this->formval_callbacks->_username_check(); // no arguments passed
    

    Try

    echo $this->formval_callbacks->_username_check('Bob'); // Bob is just an example username given
    
    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题