Welcome Guest, Not a member yet? Register   Sign In
show_error function
#1

[eluser]cinewbie81[/eluser]
I use CI built-in show_error function to display all my error message ..
For EG: Login

When user login with the wrong name , I'll use show_error("Incorrect Login Name") ..

but then my friend told me that it's very unprofessional way to display the error message ... he suggest to prompt out a message dialog or something ? How can i achieve it using CI anyone ?
#2

[eluser]Developer13[/eluser]
I don't see anything wrong with simply displaying the message on the page without using a dialog box. Many of the world's largest and most prominent websites do it that way.

If you really wanted to do the dialog box, simple javascript would do the trick.
#3

[eluser]ejangi[/eluser]
I'm doing a project at the moment where I use this kind of feature. I included the OB Session library (Though, I'm sure most other session libraries will do the same thing) which includes two very helpful methods:
- set_flashdata();
- flashdata();

Which store messages across requests. So, for instance in one of my controllers I have:
Code:
function login()
{
    $username = $this->input->post('username');
    $password = $this->input->post('password');

    if ($this->authentication->login($username, $password)) {
        $this->session->set_flashdata('msg','You are now logged in!');
        redirect('tasks/mine');
    } else {
        $this->session->set_flashdata('msg','Authentication failed, please use a valid username and password.');
        redirect('account/login');
    }
}

and then in the view for say login.php:
Code:
<?php if ($flash_msg = $this->session->flashdata('msg')): ?>
    <div id="msg">
        &lt;?php echo $flash_msg; ?&gt;
    </div>
&lt;?php endif; ?&gt;

The issue that your friend is trying to point out is that with the show_error(); method, it dead-ends the user and doesn't present them with any options which is a usability no-no. You should always give the user options. So, in my case, if the user puts the wrong password in they immediately taken back to the login screen so they can enter the correct password.




Theme © iAndrew 2016 - Forum software by © MyBB