[英]why page get blank after submit form and set set_flashdata before redirect in codeigniter
I am making a form in CI and submit the form. 我正在用CI制作表格并提交表格。 After submitting, the page redirects to another page but before redirect I am use
set_flashdata
but without using set_flashdata
my form submits successfully and page redirects to another page. 提交后,页面重定向到另一个页面,但是在重定向之前,我使用
set_flashdata
但不使用set_flashdata
我的表单成功提交,页面重定向到另一个页面。 But when using set_flashdata
then it doesn't redirect and loads a blank page and then the site stops working and all another pages of my site load a blank page. 但是,当使用
set_flashdata
它不会重定向并加载空白页面,然后该站点停止工作,并且我站点的所有其他页面均加载一个空白页面。
{
$this->load->helper('file');
$data = $this->input->post('data');
if ( ! write_file('./application/modules/widgets/'.$alias.'.php', $data))
{
//$this->session->set_flashdata('msg', '<div class="alert alert-error">'.lang_key('unable_to_write_widget').'</div>');
}
else
{
//$this->session->set_flashdata('msg', '<div class="alert alert-success">'.lang_key('widget_data_updated').'</div>');
}
}
redirect(site_url('admin/widgets/edit/'.$alias));
A blank page can mean PHP errors are being suppressed. 空白页可能意味着PHP错误被抑制。 Set CI_ENV to
development
and you'll see any PHP errors. 将CI_ENV设置为
development
,您将看到任何PHP错误。 (ENV or .htaccess usually, but you can (not recommended) set it in the index.php file too) (通常是ENV或.htaccess,但您也可以 (不建议)在index.php文件中进行设置)
Make sure your application/config.php
file is properly configured for sessions. 确保为会话正确配置了
application/config.php
文件。 If you're using files, make sure the sess_save_path
is there and writable by sessions. 如果您使用的是文件,请确保
sess_save_path
在此处并且可由会话写入。 The last 3-4 version releases will absolutely throw up and die if not configured properly. 如果配置不正确,最后的3-4版本绝对会死机。
I'll assume you've already looked at this, but it's a good reference to toss in here anyway. 我认为您已经看过了,但是无论如何,这都是一个很好的参考。 I mention it because you're saying when you call
$this->session
everything fails. 我提到它是因为您说的是,当您调用
$this->session
所有操作都会失败。
https://www.codeigniter.com/user_guide/libraries/sessions.html https://www.codeigniter.com/user_guide/libraries/sessions.html
Slightly off topic, redirect()
can add site_url()
so you don't need to do that. 稍微偏离主题的是,
redirect()
可以添加site_url()
因此您不需要这样做。 Just add you URI. 只需添加您的URI。
redirect('admin/widgets/edit/' . $alias);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.