Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter:重定向和加载视图之间的flashdata_Php_Codeigniter_Redirect_Message - Fatal编程技术网

Php Codeigniter:重定向和加载视图之间的flashdata

Php Codeigniter:重定向和加载视图之间的flashdata,php,codeigniter,redirect,message,Php,Codeigniter,Redirect,Message,在控制器注册中 function signup() { if('user already exists') { $this->session->flashdata('flsh_msg', 'You have already signed up using goole. you will be redirected to home page.'); redirect('signup/signup/show_message'); } }

在控制器注册中

    function signup() { 
     if('user already exists') {
     $this->session->flashdata('flsh_msg', 'You have already signed up using goole. you will be redirected to home page.');
    redirect('signup/signup/show_message'); 
     }
 }
在同一控制器中显示消息,仅显示视图

 function show_message()
  {
      $this->load->view('header/header');
      $this->load->view('signup/signup_message');
      $this->load->view('footer/footer');
  }
在视图文件中:

<div class="alert alert-success">
    <?php echo $this->session->flashdata('flsh_msg'); ?>
</div>

我无法显示“您已使用谷歌注册。您将被重定向到主页。”查看消息时,我已测试了keep_flashdata和set_flashdata

还有其他方法吗?如何在重定向和调用视图之间传递flash消息

function signup() { 
    if('user already exists') {
       $this->session->set_flashdata('flsh_msg', 'You have already signed up using goole. you will be redirected to home page.');
          redirect('signup/signup/show_message'); 
    }
}
flashdata的设置功能由flashdata设置,而不仅仅是flashdata。。只有flashdata(“flsh_msg”)将获取该字符串,但set_flashdata set;)

更改控制器:

视图保持原样:


希望这对你有帮助。谢谢

//控制器
$this->session->set_flashdata('flsh_msg','您已经使用谷歌注册了。您将被重定向到主页');
重定向(“注册/注册/显示消息”);
//看法

//如果('user ready exists'){//它来自哪里?它是变量吗?不,它只是一个条件,在这里我选中了“isset”,如果返回计数大于0,等等。我刚才提到的不是写条件代码,而是使用文本“用户已存在”它是否工作?请检查我下面的答案?我得到的是flsh#U msg的空白值。$this->session->set_flashdata('flsh#U msg','”);echo#r($this->session->all_userdata());数组([session_id]=>1f85e93b142e5bf0b96d802e9c0168c4[ip_地址]=>127.0.0.1[user_agent]=>Mozilla/5.0(X11;Ubuntu;Linux i686;rv:35.0)Gecko/20100101 Firefox/35.0[最后一次_活动]=>1424770709[user_数据]=>flash:new:flsh_msg]=>)问题是flashdata。更改为set_flashdata..谢谢!!@Mangeshathein没问题,如果您对我的答案感到满意,请单击该箭头并将我的答案标记为正确,谢谢:)Daniel Rossko Rosa…投票需要15个声誉。我只有10个。虽然此代码可能会解决问题,但一个好的答案应该解释代码的作用以及它的帮助方式
$this->session->set_flashdata('flsh_msg', 'You have already signed up using goole. you will be redirected to home page.');
<?php echo $this->session->flashdata('flsh_msg'); ?>
$this->session->set_flashdata('flsh_msg', 'You have already signed up using goole. you will be redirected to home page.');
//Controller

$this->session->set_flashdata('flsh_msg', 'You have already signed up using goole. you will be redirected to home page.');
redirect('signup/signup/show_message'); 

//View

<?= $this->session->flashdata('flsh_msg'); ?>