我的错误消息运行良好,但我不知道如何在会话的闪存数据中输出成功消息。
<div class="tpl-callbacks" id="tpl-callback">
<?php
if( $this->session->flashdata('message') )
$message = $this->session->flashdata('message');
if( $this->session->flashdata('error') )
$error = $this->session->flashdata('error');
if( $this->session->flashdata('success'))
$success = $this->session->flashdata('success');
// THIS WORKS WITHOUT FLASHDATA
if(function_exists('validation_errors') && validation_errors() != '')
$error = validation_errors();
// AND HOW TO DO THE SAME BUT FOR SUCCESS AND WITHOUT FLASHDATA ?
?>
<?php if( !empty($error) ):?>
<div class="alert alert-error">
<a class="close" data-dismiss="alert">×</a>
<?php echo $error;?>
</div>
<?php endif;?>
<?php if( !empty($success) ):?>
<div class="alert alert-success">
<a class="close" data-dismiss="alert">×</a>
<?php echo $success;?>
</div>
<?php endif;?>
</div>
因此,每当我在提交后进行表单检查时,我都可以在 flashdata 中输出错误消息和成功消息,但我不知道如何在不使用 flashdata 的情况下显示成功消息:
if($this->form_validation->run() == FALSE){
// $this->session->set_flashdata('error', validation_errors()); // <-- THIS WORKS IN FLASHDATA
validation_errors(); <-- THIS WORKS BUT WITHOUT FLASHDATA, WHICH IS GOOD ALSO
}else{
// Set the callback message
$this->session->set_flashdata('success', 'Success!'); // <-- THIS WORKS IN FLASHDATA
// AND HOW I SHOULD DO THE SAME, BUT WITHOUT FLASHDATA ?
// SO IT WILL WORK WITH MY MAIN TEMPLATE.PHP
}
有人可以指出我正确的答案,或者给我一个提示什么来实现这个结帐?
谢谢