This script creates the form, and outputs a message on sucess. */ // your email address - so you get copies - in case of abuse. $my_email = 'fantasticfacts@yahoo.com'; // set the safe domains to your own domain names $safe_domains = array('www.fantastic-facts.com', 'fantastic-facts.com'); // check if we are being submitted, and if we are, process it and output a message if ((isset($_POST['email_friend'])) && ($_POST['email_friend'] == 'Recommend') ) { addslashes(extract($_POST)); // this is the message you send when the form is completed. // DO NOT remove any words enclosed in "< >" as they get substituted for form values $message = ' Hello Your friend (), visited our website at: http://www.fantastic-facts.com/ and wanted to share it with you. Fantastic-Facts.com is a website dedicated to providing an encyclopedia of facts in a fun and informative way. Best of all, it is a free service which can be accessed from anywhere around the world, anytime, providing you have a computer and internet access. So what are you waiting for... check it out for yourself. And remember to recommend us to your families and friends. We hope you enjoy using our website. '; // No need to modify ANYTHING below. // Check REFERER to minimise Abuse $i = count($safe_domains) - 1; while ($i >= 0) { if (strpos($_SERVER['HTTP_REFERER'], "http://$safe_domains[$i]") === 0) { $safe = "yes"; } $i--; } // make sure form fields have been filled in, name is optional if ( ($safe == "yes") && (($tellemail != '' ) || ($tellfriend != '' ))) { $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"; $sendervalid = 'Nope'; $rxvalid = 'Nope'; if (eregi($regexp, $tellemail)){ $sendervalid = 'Yes'; } if (eregi($regexp, $tellfriend)){ $rxvalid = 'Yes'; } if (($sendervalid == 'Yes') && ($rxvalid == 'Yes')) { // valid to and from address $good = 'yes'; } } if ($good =='yes') { // form data validated. $subject = 'Your friend recommends Fantastic-Facts.com'; $headers = "From: <$tellemail>\r\n"; $fmtMail = str_replace("", $tellfriend, $message); $fmtMail = str_replace("", $tellname, $fmtMail); $fmtMail = str_replace("", $tellemail, $fmtMail); $frommail = $_SERVER["REMOTE_ADDR"]; $fmtMail2 = "$fmtMail \n\n Remote IP is $frommail \n\n\n"; //echo "$tell_friend - $subject \n"; // send message mail($tellfriend, $subject, $fmtMail, $headers, "-f$tellemail"); // send message to admin address mail($my_email, $subject, $fmtMail2, $headers, "-f$tellemail"); // output message echo "Recommend More\n
\n"; } } ?>
Your name:

Your e-mail:

Friend's e-mail: