◆ After setting the score per each friend, the total score for the originator is calculated and set at the bottom of the template. ◆ At the end, the template is parsed and printed to the user to give her a scorecard report. Installing a Tell-a-Friend System Here I assume that you’re using a Linux system with MySQL and Apache server installed. Your Internet web server document root directory is /evoknow/ intranet/htdocs . Of course, if you have a different path, which is likely, you should change this path whenever you see it in a configuration file or instruction in this chapter. During the installation process, I refer to this directory as %DocumentRoot%. I also assume that you’ve installed the PHPLIB and PEAR library. Normally, these get installed during PHP installation. For your convenience, I’ve provided these in the lib/phplib.tar.gz and lib/pear.tar.gz directories on the CD-ROM. In these sample installation steps, I assume that these are installed in the /%DocumentRoot%/phplib and /%DocumentRoot%/pear directories. Because your installation locations for these libraries are likely to differ, make sure you replace these paths in the configuration files. Here is how you can get your Tell-a-Friend applications up and running: 1. Install the application framework. If you have not yet installed the appli- cation framework discussed in Chapter 4, you must do so before proceed- ing further. 2. Install the Tell-a-Friend Database. The quickest way to create the Tell-a- Friend database is to run the following commands: mysqladmin –u root –p create TELL_A_FRIEND mysql –u root –p –D TAF < taf.sql 3. Install the Tell-a-Friend applications. Now from the ch13 directory on the CD-ROM, extract ch13.tar.gz in %DocuemntRoot%. This will create taf in your document root. Configure %DocumentRoot%/taf/apps/ contact.conf for path and database settings. The applications are installed in the %DocumentRoot%/taf/apps directory and the templates are stored in %DocumentRoot%/taf/apps/templates. If your MySQL server is hosted on the web server, it can be accessed via localhost. However, if this is not the case, you can easily modify the data- base URLs in each application’s configuration files. For example, the con- tact.conf file has a MySQL database access URLs such as the following: define(‘TAF_DB_URL’,’mysql://root:foobar@localhost/TELL_A_FRI END’); Chapter 13: Tell-a-Friend System 461 17 549669 ch13.qxd 4/4/03 9:26 AM Page 461 Say your database server is called db.domain.com and the user name and password to access the TELL_A_FRIEND databases (which you will create during this installation process) are admin and db123. In such a case, you would modify the database access URLs throughout each configuration file as: define(‘TAF_DB_URL’,’mysql://admin:db132@db.domain.com/TELL_A _FRIEND’); If you change the database name from TELL_A_FRIEND to some other name make sure the database prefix in the following configuration lines are changed accordingly: /* DEFINE TABLE NAMES */ define(‘TAF_FRM_TBL’, ‘TELL_A_FRIEND.TAF_FORM’); define(‘TAF_FRM_OWNER_IP_TBL’, ‘TELL_A_FRIEND.TAF_FRM_OWNER_IP’); define(‘TAF_FRM_RESTRICT_IP_TBL’, ‘TELL_A_FRIEND.TAF_FRM_BANNED_IP’); define(‘TAF_MSG_OWNER_IP_TBL’, ‘TELL_A_FRIEND.TAF_MSG_OWNER_IP’); define(‘TAF_MSG_TBL’, ‘TELL_A_FRIEND.TAF_MESSAGE’); define(‘TAF_FRM_SUBMTN_TBL’, ‘TELL_A_FRIEND.TAF_SUBMISSION’); define(‘TAF_SUBSCRIPTION_TBL’, ‘TELL_A_FRIEND.TAF_SUBSCRIPTION’); 4. Set file/directory permissions. Make sure you’ve changed the file and directory permissions such that your intranet web server can access (read) all the files. After you’ve performed the preceding steps, you’re ready to test your Tell-a- Friend applications. Testing the Tell-a-Friend System Now that you’re ready to test your system, the very first step is to create a Tell-a- Friend form. I’ve supplied two sample Tell-a-Friend forms called sample_taf_ form1.html and sample_taf_form2.html in the taf directory. 462 Part III: Developing E-mail Solutions 17 549669 ch13.qxd 4/4/03 9:26 AM Page 462 To set up a Tell-a-Friend form, you need to do the following: ◆ Create three messages using Tell-a-Friend message manager. ■ One message is for friends who get e-mail because another friend gives their name and information to your Tell-a-Friend system. This e-mail should introduce the friend to what you have to offer. For example, if you’re interested in signing up people for a newsletter, you should state what the newsletter has to offer in this message. This message is created using the taf_frnd_msg.html template file in the template directory. So if you want to control the look and feel of this message, you should modify this template. Make sure if you use any images in the template, the images are directly accessible from your Web site. In other words, use fully qualified path names for images. For example, instead of using <img src=images/space.gif”> use <img src=”http://yourserver/images/space.gif”>. Remember: This is a message template for all messages to friends, so don’t cus- tomize it for a single campaign. Your actual content of the message is entered via the form manager application. The content is inserted dynamically into the message template by replacing the {FRND_MSG} tag in the template. ■ The second message you need to set up is for the originator who sub- mits the friend’s name. This is usually a thank-you message for helping you market your product/services/information. This message is sent using the taf_frnd_msg.html template. The actual content of the mes- sage is entered via the form manager like the friend’s message. ■ The third message is the subscription message and it’s sent when a friend actually clicks on the subscription link (in the introduction mail generated by taf_frnd_msg.html) and subscribes to your offer. Note that when a friend decides to unsubscribe, she does not receive an e-mail, but a confirmation of her unsubscription status is shown on the web browser when she clicks on the remove or unsubscription link from the introduction mail. ◆ Create the form with a form action that runs the Tell-a-Friend form processor application. When you set up the form with the Tell-a-Friend form manager, the form action is given to you at the end of the process, so you can simply copy and paste the form action from there. After you’ve set up the messages and the Tell-a-Friend form, you can use your form in e-mail campaigns. In the following section, I discuss a Tell-a-Friend campaign from setup to execution. Chapter 13: Tell-a-Friend System 463 17 549669 ch13.qxd 4/4/03 9:26 AM Page 463 Creating Msg for Friend (Introduction Msg) The first step is to create an introductory message for the friends who would be referred by other friends filling out the Tell-a-Friend form. Run http://yourserver/taf/apps/taf_mngr.php, which should bring up a menu interface as shown in Figure 13-3. Figure 13-3: Tell-a-Friend system main menu. Click on the Add a New Message link, which will show the screen shown in Figure 13-4. Fill out this form and decide if you want to restrict access to this message by IP/network. For example, if you don’t want anyone to modify or delete this mes- sage from somewhere else, and you have a static IP network (most offices do), you can enter the IP address of your PC or the network in the Restrict Message Setup to IP Networks field. For your convenience, your current IP address is shown on the top of the form. Similarly, add two other messages: one for the originator who refers friends via the Tell-a-Friend form and the other for the friend who decides to subscribe by clicking on the subscription link shown by the very first message she gets from your Tell-a-Friend system. When you have three messages set up, you’re ready to set up a Tell-a-Friend form. From the main menu, click on the Setup a Tell-a-Friend Form link, which shows a screen similar to Figure 13-5. 464 Part III: Developing E-mail Solutions 17 549669 ch13.qxd 4/4/03 9:26 AM Page 464 Figure 13-4: Adding the message for friends. Figure 13-5: Setting up a Tell-a-Friend form. Chapter 13: Tell-a-Friend System 465 17 549669 ch13.qxd 4/4/03 9:26 AM Page 465 . assume that you’ve installed the PHPLIB and PEAR library. Normally, these get installed during PHP installation. For your convenience, I’ve provided these in the lib/phplib.tar.gz and lib/pear.tar.gz. CD-ROM. In these sample installation steps, I assume that these are installed in the /%DocumentRoot%/phplib and /%DocumentRoot%/pear directories. Because your installation locations for these libraries. be referred by other friends filling out the Tell-a-Friend form. Run http://yourserver/taf/apps/taf_mngr .php, which should bring up a menu interface as shown in Figure 13-3. Figure 13-3: Tell-a-Friend