Creating a View Page and Building the Comments System

The purpose of this section is to show the contacts of the CRUD in operation. The following screenshot shows you what we're planning to accomplish by the end of this section.

Creating a View Page and Building the Comments System

The comments system

To make our contacts section more useful, let's add a view page where we can see an individual contact. The view page is also a perfect place to build a comments system to add comments against the contact:

  1. Open your Contacts controller and create a new method called view($id).
  2. Check that the $id is numeric and then load the contact from get_contact($id). If $contact is empty, redirect to a 404 page.
  3. Set the ...

Get Beginning PHP now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.