◆ Then it shows an interface that allows the user to map each standard personalization field to a database field.. If these fields are empty, then an alert message is shown and the user
Trang 1If the database is successfully updated, the modifyList() method calls takeMap() to show the database and personalization field map interface If the update fails, it shows an appropriate status message
modifyDatabaseFieldMap( )
This method uses a listobject to call its modifyMapList()method to update the map data in the database The map interface is displayed by the takeMap()method
delList( )
This method uses a listobject to call its deleteList()method to delete the list
It displays an appropriate status message based on the success or failure of the deleteList()method
takeMap( )
This method allows you to map the database fields to the standard personalization fields REC_ID, EMAIL, FIRST, LAST, AGE, INCOME, and SEX It works as follows:
◆ It connects to the list database using a DBIobject called $dbiObj
◆ If the connection to the list database is successful, it performs a select query to detect if the list table exists in the list database If the table does not exist, the list is deleted from the database
◆ If the table exists, the takeMap()method uses the tableInfo()method
on the query result object, $result, to get the list table’s meta data — field name and type
◆ Then it shows an interface that allows the user to map each standard personalization field to a database field The user must map at least REC_ID(record ID) and the EMAIL(email address)
addList( )
This method is called when a user makes changes in the add interface shown by displayAddListMenu() It works as follows:
◆ First, it checks to see if the user supplied all the required fields: list name ($listname), database host name ($db_host), database user name ($db_user), database type ($db_type), database table name ($db_table)
If these fields are empty, then an alert message is shown and the user is returned to the previous screen
◆ If the required fields are supplied, a listobject called $ecampaignListObj
is created and its addNewEcampaignList()is called to add the list in the database
Trang 2◆ If the list is successfully added, the takeMap()method is called to display the map interface
◆ If the list is not added due to database failure, an appropriate failure message is displayed
addDatabaseFieldMap( )
This method adds database fields to standard personalization field mapping to the database using a listobject’s addMapping()method
Creating a URL Manager Application
The URL manager allows you to add, delete, and modify trackable URLs Figure 15-4 shows how URLs are added to the database using a simple user interface, how it’s used in a message template using the {URLx}tag and replaced with a redirection URL in the message received by end-users, and how the redirection URL is finally resolved in the final target URL being tracked
The ecampaign_url_mngr.php, which can be found in ch15/appsdirectory in the CDROM implements the URL manager application using the methods discussed
in the following sections
run( )
This method uses a form variable called $cmd variable, which is set in the user interface displayed by ecampaign_mngr.php, to select the appropriate function to implement the list operation
When $cmd is set to delete, it calls the delList() method to delete a URL When $cmdis set to modify, it calls the modifyURL() method to modify a URL; otherwise, it calls the addURL()method to add a URL
addURLDriver( )
This method controls the add URL process using the interface variable $step Here’s how it works:
◆ If $stepis not set, then displayAddURLMenu()is called to display the add URL interface This interface sets $stepto 2, using a hidden HTML field
◆ If $stepis set to 2, then addURL()is called to add the URL in the database
authorize( )
See the authorize() method in the e-campaign user interface application called ecampaign_mngr.phpfor details
Trang 3Figure 15-4: How the URL is stored, tracked, and redirected.
modifyURLDriver( )
This method controls the modify URL process using the interface variable $step Here’s how it works:
◆ If $stepis not set, then displayModifyURLMenu()is called to display the add URL interface This interface sets $stepto 2, using a hidden HTML field
◆ If $stepis set to 2, then modifyURL()is called to modify the URL in the database
Name EVOKNOW PHP Site URL
URL_ID 1
NAME EVOKNOW PHP Site
URL http://www.evoknow.com/php/
http://www.evoknow.com/php
Click <a href="{URL1}">here</a> to visit our PHP site.
Click <a
href="http://evoknow.com/apps/redir.php?u=1&c=1&uid=12&chk=939322">
here</a> to visit our PHP site.
EVOKNOW PHP Site
User interface
E-campaign Database
Message Template
Source of Sent Message
URL Tracking &
Redirection Application
http://www.evoknow.com/php/
Trang 4delURL( )
This method deletes a URL from the database It works as follows:
◆ If the URL is not selected from the e-campaign main interface, then an alert message is shown and the user is returned to the main interface
◆ It creates a URLobject and calls its deleteURL()method to delete the selected URL from the database
◆ Finally, it shows a status message that reflects the status of the database delete operation
displayAddURLMenu( )
This method displays the add URL interface
addURL( )
This method adds a URL in the database It works as follows:
◆ If the required fields — URL ($url) and URL name ($name) — are missing, then an alert message is shown and the user is returned to the previous screen
◆ A URLobject is created and its addURL()method is called to store the URL
in the database
◆ Finally, the status of the add operation is displayed
displayModifyURLMenu( )
This method displays the modify URL interface
modifyURL( )
This method modifies a URL in the database It works as follows:
◆ If the required fields — URL ($url) and URL name ($name) — are missing, then an alert message is shown and the user is returned to the previous screen
◆ A URL object is created and its modURL()method is called to update the URL in the database
◆ Finally, the status of the modify operation is displayed
Trang 5Creating a Message Manager Application
The message is the central element of the e-campaign system Figure 15-5 shows a simple message that is stored in the database It contains personalization tag {FIRST}, multiple URL tags {URL1}and {URL99}, and the unsubscription tag {UNSUB}
When this message is executed by the message execution application, a sample
of the resulting end-user message is also shown in Figure 15-5
Figure 15-5: The anatomy of a Campaign message.
A message manager application called ecampaign_message_mngr.php, which can be found in ch15/appsdirectory in the CDROM, provides the message addition, modification, deletion, and preview functionality using the methods discussed in the following sections
Dear {FRIST}
<p>
The message contents can be personalized with other fields such as last name, email address, age, gender, etc.
</p>
<p>
Click <a href="{URL1}"> here</a> to buy PHP applications.<br>
Click <a href="{URL99}"> here</a> to learn more.<br>
</p>
To subscribe click <a href="{UNSUB}">here</a>.
Dear {FRIST}
The message contents can be personalized with other fields such as last name, email address, age, gender, etc.
Click here to buy PHP applications.
Click here to learn more.
To unsubscribe click here.
Message Template
Rendered Message