Ready to watch this entire course?
Become a member and get unlimited access to the entire skills library of over 4,900 courses, including more Developer and personalized recommendations.Start Your Free Trial Now
- View Offline
Starting with the what and why of CodeIgniter, Jon introduces key concepts such as the MVC pattern and libraries by demonstrating how to create static pages, then storing and displaying magazine info in a database. Advanced topics like classes and helpers are explored to validate user input, upload files, and much more. By creating a complete system, you'll have the foundation to build your own applications with CodeIgniter.
- What is CodeIgniter?
- Creating a static page controller
- Generating output with a view
- What is a model?
- Saving data with Active Records
- Creating forms
- Validating user input
- Listing records in tables
- Uploading images
- Viewing and deleting records
Skill Level Intermediate
The CodeIgniter input class, which is initialized automatically, serves two purposes. Securely pre-processing global input data, and providing helper functions for getting input data. Among other things, it destroys global variables if register_globals is turned on. Filters the GET, POST and COOKIE array keys, and provides optional cross site scripting attack filtering. Let's go back to the magazine controller. Before I show the success message, let's save a new magazine issue. I'll start by loading the model. This -> load -> model issue.
Then, I'll create a new instance of the issue model. Issue equals new issue. I'll set the publication ID, issue -> publication id equals this, and I'm going to use the input class post method with one argument. So input -> post, a string containing the element I'm looking for, which is the publication id. I'll do the same for the issue_number, equals this -> input -> post -> issue_number, and the issue date of publication.
Issue -> issue -> date publication equals this -> input -> post Issue_date_publication. Tell the issue to save itself. Let's make this success message a tiny bit more verbose by passing the issue to the view. So, comma array, set a key called issue, and assign it to the issue itself. Save the controller, then open the magazine form success view.
I'm going to echo the HTML escaped issue, Issue ID. So, magazine number PHP echo html_ escape issue -> issue_id. Close it out, put in a space, and then save the view. Let's go back to the browser and refresh. It'll ask me if I wish to confirm the re-submission of the form. Say yes. Now, I see a message saying that magazine number two has been created.
However, if I navigate back to the root page, I don't see a list containing the magazines I created, I only see the one that is being loaded by ID. Let's fix that.