wmguk Posted August 20, 2007 Share Posted August 20, 2007 Hey, I found this on the internet, but it seems to have failed. <?php //You will need to configure the script. //It's easy, just use a text editor. //Follow the instructions in the "Begin Configure" section below. //Note: This script contains a link to our site. //We'd like it if you left it, but you have permission to remove it. //This script uses the new $_POST and $_SERVER['HTTP_REFERRER'] //If you have an issue with an older version of PHP, you can get help at: // ************Begin Configure*************** //Put your website name between the quotes below: $websiteName = "Imagine Wedding Photography"; //Put your website address between the quotes below: $websiteAddress = "www.iwphoto.co.uk"; // If you have a privacy policy, put in the link title: $privacyPolicyLinkText = ""; // Put in the "" the url to you your privacy policy, if you have one, $privacyPolicyLinkURL = ""; // Change the 0 to a 1 below, //if you want to recieve a notice when people are refered: $notice = 1; //Put your email address in the " " if you changed the notice to 1 $adminEmail = "drew@wmguk.co.uk"; //Put the subject line text you want the email to read in the "": $subject = "Our album is now live"; //Specify $login $login = $_GET['login']; // Put your default message intro text in the first set of quotes below //This is what the people who are referred will see //along with any personal message entered by the referer. $defaultMessageIntro = "<html>\n<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:8px; color:#666666;\">\n<table width='800' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td height='80' align='left' valign='top' background='http://demo.iwphoto.co.uk/images/top.jpg'><p> </p></td></tr><tr><td align='left' valign='top' background='http://demo.iwphoto.co.uk/images/middle.jpg'><table width='800' border='0' cellspacing='0' cellpadding='0'><tr><td width='20'> </td><td class='main'>We are pleased to announce that the album for $title is now viewable.</p><p>Please click <a href='http://demo.iwphoto.co.uk/emailgallery.php?login=$login'>HERE</a> to view the album. </p></td><td width='20'> </td></tr></table></td></tr><tr><td align='left' valign='top' background='http://demo.iwphoto.co.uk/images/bottom.jpg'> </td></tr></table></body>\n</html>\n"; //Put in the "" your default close (this will be at the end of the message): $defaultMessageClose = ""; // ************End Configure**************** // Set the link that will be in intro/invite and used to send the referer back if (isset($_POST['link'])) { $link = $_POST['link']; } else { if (empty($_SERVER['HTTP_REFERER'])) { $link = 'http://' . $websiteAddress; } else { $link = $_SERVER['HTTP_REFERER']; } } // Add the link to the intro $defaultMessageIntro = $defaultMessageIntro . $link . "\n"; //Adds a space infront of the subject line (to add a name latter $subject = ' ' . $subject; ?> <?php function doTellForm ($privacyPolicyLinkText, $privacyPolicyLinkURL, $defaultMessageIntro, $link) { // If you understand HTML, you can make changes to the form layout below. // I just copy the HTML from the "<form" opening to the "</form>" // Put it into Dreamweaver (WYSIWYG Editor), work on it and put it back. $theForm = <<<EOD <form name="tellForm" method="post" action=""> <br /><br /><table width="500px" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td class="main"width="50%"><div align="center">Your name:</div></td> <td class="main"width="50%"><div align="center">Your email:</div></td> </tr> <tr> <td> <div align="center"> <input class="main" name="your_name" type="text" id="your_name"> </div></td> <td> <div align="center"> <input class="main" name="your_email" type="text" id="your_email"> </div></td> </tr> <tr> <td><div align="center"></div></td> <td><div align="center"></div></td> </tr> <tr> <td class="main"><div align="center"><br />Enter the name(s) of your friend(s):</div></td> <td class="main"><div align="center"><br />Enter the email(s) of your friend(s):</div></td> </tr> <tr> <td> <div align="center"> <input class="main" name="friend_name1" type="text" id="friend_name1"> </div></td> <td width="50%"> <div align="center"> <input class="main" name="friend_email1" type="text" id="friend_email1"> </div></td> </tr> <tr> <td> <div align="center"> <input class="main" name="friend_name2" type="text" id="friend_name2"> </div></td> <td> <div align="center"> <input class="main" name="friend_email2" type="text" id="friend_email2"> </div></td> </tr> <tr> <td> <div align="center"> <input class="main" name="friend_name3" type="text" id="friend_name3"> </div></td> <td> <div align="center"> <input class="main" name="friend_email3" type="text" id="friend_email3"> </div></td> </tr> <tr> <td colspan="2"><p align="center"> <input class="main" type="submit" name="Submit" value="Tell them"> </p> <p align="center"><a href="$privacyPolicyLinkURL" target="_blank">$privacyPolicyLinkText</a><br></td> </tr> </table> <div align="center"> </div> </form> EOD; echo ($theForm); } ?> <?php function spamcheck($array) { # returns true if data is ok, otherwise false if it is spam-looking return (!preg_match("/(MIME-Version:|Content-Type:|\n|\r)/i", join('',array_values($array)) )); } function myMailFunction($mailto, $subject, $message, $headers, $defaultMessageClose, $adminEmail, $notice) { $message = $message . "\n\n" . $defaultMessageClose; // Check for suspected spam content if (!spamcheck(array($mailto,$subject,$headers))) { die('no spam please'); } if (@mail($mailto, $subject, $message, $headers)) { echo ('<p>Your message was successfully sent to ' . $mailto . '</p>'); if ($notice == 1) { $message = "From email " . $headers . "\n\n" . "To email " . "\n\n" . $mailto . "\n\n" . $message; @mail($adminEmail, "Referal notice", $message); } } else { // This echo's the error message if the email did not send. // You could change the text in between the <p> tags. echo('<p>Mail could not be sent to ' . $mailto . ' Please use your back button to try them again.</p>'); } } ?> <?php function doTell ($notice, $adminEmail, $subject, $websiteName, $defaultMessageClose, $link) { if ($_POST['your_email'] != "") { $headers = 'From: ' . $_POST['your_name'] . '<' . $_POST['your_email'] . '>'; } else { $headers = 'From: ' . $websiteName . '<' . $adminEmail . '>'; } if ($_POST['friend_email1'] != "") { $mailto1 = $_POST['friend_email1']; //This tacs the name onto the subject line $subject1 = $_POST['friend_name1'] . $subject; //This tacs the name onto the message $message1 = $_POST['friend_name1'] . "\r\n" . $_POST['message']; myMailFunction($mailto1, $subject1, $message1, $headers, $defaultMessageClose, $adminEmail, $notice); } if ($_POST['friend_email2'] != "") { $mailto2 = $_POST['friend_email2']; //This tacs the name onto the subject line $subject2 = $_POST['friend_name2'] . $subject; //This tacs the name onto the message $message2 = $_POST['friend_name2'] . "\r\n" . $_POST['message']; myMailFunction($mailto2, $subject2, $message2, $headers, $defaultMessageClose, $adminEmail, $notice); } if ($_POST['friend_email3'] != "") { $mailto3 = $_POST['friend_email3']; //This tacs the name onto the subject line $subject3 = $_POST['friend_name3'] . $subject; //This tacs the name onto the message $message3 = $_POST['friend_name3'] . "\r\n" . $_POST['message']; myMailFunction($mailto3, $subject3, $message3, $headers, $defaultMessageClose, $adminEmail, $notice); } $return = <<<EOD <p align="center"><a href="$link">Return to the page you left.</a></p> EOD; echo ($return); } ?> <?php if (isset($_POST['tellsubmit'])) { doTell($notice, $adminEmail, $subject, $websiteName, $defaultMessageClose, $link); } else { doTellForm($privacyPolicyLinkText, $privacyPolicyLinkURL, $defaultMessageIntro, $link); } ?> anything screaming at you? Quote Link to comment https://forums.phpfreaks.com/topic/65809-creating-an-email-a-friend-script/ Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 but it seems to have failed. well thats as useful as it works as its be programmed to! Quote Link to comment https://forums.phpfreaks.com/topic/65809-creating-an-email-a-friend-script/#findComment-328798 Share on other sites More sharing options...
wmguk Posted August 20, 2007 Author Share Posted August 20, 2007 it just refreshes the page to itself but doesnt actually send any email or say its sent any emails Quote Link to comment https://forums.phpfreaks.com/topic/65809-creating-an-email-a-friend-script/#findComment-328803 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 No i mean that not useful infomation.. what do you mean by "but it seems to have failed." its like saying "theirs a problem" Quote Link to comment https://forums.phpfreaks.com/topic/65809-creating-an-email-a-friend-script/#findComment-328805 Share on other sites More sharing options...
php_tom Posted August 20, 2007 Share Posted August 20, 2007 [code]Here's you problem: change if (isset($_POST['tellsubmit'])) { doTell($notice, $adminEmail, $subject, $websiteName, $defaultMessageClose, $link); } else { doTellForm($privacyPolicyLinkText, $privacyPolicyLinkURL, $defaultMessageIntro, $link); } [/code] to if (isset($_POST['Submit'])) { doTell($notice, $adminEmail, $subject, $websiteName, $defaultMessageClose, $link); } else { doTellForm($privacyPolicyLinkText, $privacyPolicyLinkURL, $defaultMessageIntro, $link); } (It's at the bottom of the script.) Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/65809-creating-an-email-a-friend-script/#findComment-328807 Share on other sites More sharing options...
wmguk Posted August 20, 2007 Author Share Posted August 20, 2007 ah ha, excellent ta, thats got it, the only thing is its not including the message in the email, $message = "<html>\n<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:8px; color:#666666;\">\n<table width='800' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td height='80' align='left' valign='top' background='http://demo.iwphoto.co.uk/images/top.jpg'><p> </p></td></tr><tr><td align='left' valign='top' background='http://demo.iwphoto.co.uk/images/middle.jpg'><table width='800' border='0' cellspacing='0' cellpadding='0'><tr><td width='20'> </td><td class='main'>We are pleased to announce that the album for $title is now viewable.</p><p>Please click <a href='http://demo.iwphoto.co.uk/emailgallery.php?login=$login'>HERE</a> to view the album. </p></td><td width='20'> </td></tr></table></td></tr><tr><td align='left' valign='top' background='http://demo.iwphoto.co.uk/images/bottom.jpg'> </td></tr></table></body>\n</html>\n"; i set this as $message but its not being emailed? Quote Link to comment https://forums.phpfreaks.com/topic/65809-creating-an-email-a-friend-script/#findComment-328818 Share on other sites More sharing options...
php_tom Posted August 20, 2007 Share Posted August 20, 2007 $message1 = $_POST['friend_name1'] . "\r\n" . $_POST['message']; It's apparently looking for the message to be POSTed from the form ($_POST['message']). Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/65809-creating-an-email-a-friend-script/#findComment-328837 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.