Welcome Guest, Not a member yet? Register   Sign In
set_message Dysplay
#1

[eluser]Gabi3xz[/eluser]
Example
have code
Code:
$this->load->library('form_validation');

if ( $res !== false ) {
    $_SESSION['username'] = $this->input->post('email_address');
    //insert here set_message "Success"
    $this->form_validation->set_message('success_login', 'Login success');

            } else {
    echo "Incorrect";
   }
used
Code:
$this->form_validation->set_message('success_login', 'Login success');
and added $lang['success_login'] = "Success login."; in form validation lang and does not display message.
What is not correct?
#2

[eluser]vrencianz[/eluser]
The set_message() function is used to display error messages (See http://ellislab.com/codeigniter/user-gui...tingerrors for setails).

To display a success message

1) You can use the success page

or:

2) Create two helper functions (in a file helpers/utils_helper.php, for example)

Code:
/**
* Sets a feedback message as flashdata
* @param string $feedback
*/
function set_feedback($feedback)
{
$CI =& get_instance();

$CI->session->set_flashdata('feedback', $feedback);
}

/**
* Gets the feedback data set by set_feedback($feedback)
* @return the feedback message or FALSE if it is not set
*/
function feedback()
{
$CI =& get_instance();

return $CI->session->flashdata('feedback');
}

3) On success call <b>set_feedback('Login success');</b>

4) Somewhere in your view insert

Code:
&lt;?php if($feedback): ?&gt;
<div id="feedback">
  &lt;?=$feedback?&gt;
</div>
&lt;?php endif?&gt;

5) load your view

Code:
$this->load->helper('utils');
...
$data['feedback'] = feedback();

$this->load->view('your_view', $data);

I hope this helps.
#3

[eluser]Gabi3xz[/eluser]
Thanks, now I understand




Theme © iAndrew 2016 - Forum software by © MyBB