Chapter 13: Tell-a-Friend System 457 Creating a Tell-a-Friend (Starting a web site)

Chapter 13: Tell-a-Friend System 457 Creating a Tell-a-Friend Form Processor Application This application, taf.php, is the core part of the system that is responsible for handling the form submission requests from users. This application is included on the CD-ROM in the ch13/apps directory. It implements the following functionalities: . Processes the form submitted by the users and updates the database accordingly. . Sends appropriate mails to newly added friends and the originator of those friends. To achieve those functionalities, it uses the following methods. run() When the application is run, this method is called. It simply calls the processRequest() method to process the submit request from the user. processRequest() This method is responsible for handling the request and takes the action thereby. This is how it works: . First, it checks whether the form ID is supplied or not. If not, it shows an alert message and returns null. . Then it verifies if the originator e-mail has been provided from the form or not. If not, it returns null after showing an alert. . Then it uses the AccessControl class to check whether the request IP address is banned from submitting friends for this form. If it is banned, then it shows the appropriate alert and returns null. . Then an object of the Form class, named $frmObj, is created. . $frmObj retrieves the activation date and termination date for the form and checks whether the current time falls into a valid time range. If not, it shows an alert message and returns null.

Leave a Reply