|
|
PERL CGI Tutorial
|
Contents Getting Started in CGISend HTML Page to Browser Parse HTML Form Saving to a File Open a File and Display Contents Using the Split Function Search a File Sort a File Display a Multi Line File in Tables Display a Multi Line File in a Textarea Working with Numbers Using Sendmail |
Sendmail PHP StyleWe haven't mentioned PHP to this point for CGI operations because for the most part there isn't much difference in the coding. But for sending mail PHP is so much easier than Perl that we thought we'd throw in a special script. The next script will show you some of the elements and functions of PHP. We'll show you how to loop through an array of email addresses and associated names and send a form letter to each wihout breaking a sweat. The script is very simple. NOTE: PHP scipts are never placed in the CGI-BIN
<html>
The first part of the script defines an associative array where the email address is used as the key and the persons name is the value. Then we loop through the hash. The message is placed within the loop so that the $val data can be placed in the salutation. You can run this script as is. Just plug in some valid email addresses, finish the form letter, save it in the root directory on your server with a .php extension and run it like you would any html page. Simple Auto ResponsePerhaps you have a PHP form that takes subscriptions for a newsletter. It parses an email address as $email. Just add this little bit of code to the bottom of the page and use it as a simple autoresponder. We like PHP because your web host is responsible for all coordination of PHP with the mail server. No Muss No Fuss! |
|
|
|
|
| HTML TOC | Website Design Workshop | Home | |