Home arrow PHP arrow Page 3 - Working with the Email Class in Code Igniter

Defining a simple view file - PHP

Unless you’ve already built a PHP toolkit that lets you develop web applications by reusing its components, the best way to create complex PHP programs quickly is by means of a third-party framework, such as Code Igniter (http://codegniter.com). This package will let you build robust object-based PHP applications in literally minutes, thanks to its extremely friendly interface. So, if you’re interested in learning how to put this framework to work for you, start reading this article now!

TABLE OF CONTENTS:
  1. Working with the Email Class in Code Igniter
  2. Sending email with Code Igniter
  3. Defining a simple view file
  4. Sending email messages via an HTML form
By: Alejandro Gervasio
Rating: starstarstarstarstar / 7
October 01, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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.



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap

Dev Shed Tutorial Topics: