Working with the Email Class in Code Igniter - Defining a simple view file (
Page 3 of 4 )
In the section that you just read, I showed you how to build a basic controller class, which was provided with the capacity to send email messages in a simple fashion. Nonetheless, we need to construct the important part of the program that indicates to the user whether or not the message has been successfully dispatched.
To perform this task, I’m going to create a primitive view file, whose signature will look as simple as this:
<html>
<head>
<title><?php echo $title;?></title>
</head>
<body>
<h1><?php echo $header;?></h1>
<p><?php echo $message;?></p>
</body>
</html>
Undoubtedly, the structure of the view file shown above is extremely simplistic. As you can see, this view, aside from displaying the title along with a simple header, will show an additional message on screen which indicates that the email message has been successfully submitted, or in the worst case, that it failed to be dispatched.
It would also be possible to create two different views, where each of them would be used by the previous controller to display en error string or a confirmation message. However, in this case I decided to code only one view file to keep the example rather simple to follow.
So far, so good. At this point I've demonstrated how to use Code Igniter to develop a simple email application, whose structure has been built around the schema imposed by the MVC pattern. So, what comes next?
In the following section I’m going to explain how to take advantage once again of the email class that comes included with Code Igniter. In this case, we'll build a PHP program that sends email using the data entered in a simple HTML form.
To learn how this sample email application will be developed, you’ll have to click on the link shown below and keep reading.