Flashdata on Login

 

In this tutorial, we are going to create flash message with the help of session flashdata. 

eg. If you create a login and user enters the wrong username and password  so it will show the error message.

 

What is Flashdata

You can perform different session message depends what you pass to view file from your controller.

 

Step 1 : Create flash message in your Login controller.

eg: 

$this->session->set_flashdata('fail_login','Invalid Credentials');

 

here i am creating fail_login session name for flash message. So that it will show user's details is not correct.

 

Step 2 : Open your view file. So that we can pass fail_login message in login view page.

eg : 

//here i getting flash message name
<?php if($error = $this->session->flashdata('fail_login')){ ?>

     <p style="color: red;"><?= $error; ?></p>

<?php } ?>

 


Result :

Source Code:

Codeigniter tutorial for beginners

In this project. We are providing you, how to create small project in Codeign....

Source Code