Book Image

Programming with CodeIgniter MVC

Book Image

Programming with CodeIgniter MVC

Overview of this book

The CodeIgniter Model-View-Controller framework provides genius simplicity, flexibility, and efficient resource usage, boosting performance and reusability. "Programming with CodeIgniter MVC" reviews the unique features of CodeIgniter using simple, easy-to-follow, and practical examples. Programming with CodeIgniter MVC provides a simple step-by-step guide to efficiently utilizingthe CodeIgniter MVC framework for developing web applications. This book is packed with engaging examples to understand the usage of controllers, libraries, and (Codeigniter) CI Models. This book commences with a quick discussion of the CodeIgniter Integration with  external plugins such as Flickr API, Google Maps and more will be reviewed with clear usage examples. It will then cover CI naming convention rules, mandatory and optional configurations, and usage within a CI project. It will also cover user defined configurations. By the end of this book, you will not only understand user-defined libraries in a CI framework, but also their services, role, usage, and scope with the help of an example-based approach. The book also covers helpers, models, and views, as well as their usage. Using this book, youwill soonbe able to develop feature-rich web applications using the CodeIgniter MVC framework. "Programming with CodeIgniter MVC" is a one-stop solution to developing solutions with CodeIgniter MVC.
Table of Contents (15 chapters)
Programming with CodeIgniter MVC
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Appendix
Index

Example 2 – user feedback powered by AJAX and the jQuery UI


In this example, we will show how we can use the jQuery UI with AJAX to call a CI AJAX controller method to collect the user feedback, and submit it without refreshing/rendering a page.

We will reuse and expand the login example from Chapter 3, Usage and Scope of Controllers, so if a user is logged in, we will log the feedback with the user ID kept in the session, while if not, we will log it as anonymous user feedback.

Remember the following things:

  • Username: reg_user,

  • Password: 111111111 (9 by 1s) for regular user login

The reused and extended resources are as follows:

  • auth.php: No change here

  • ajax_handler.php: This is the new AJAX handler controller

  • users_model.php: This is the extended user model

  • logged_in_view.php: This is the extended view for regular user login

We expand the code to include the new Ajax_handler to keep the jQuery UI dialog submission of the browsing user feedback, as well as get the user logged message via the AJAX...