Location: PHPKode > scripts > Tell Friend > tell-friend-by-smartphponline-com/tellfriend.php
<?
///////////////////////////////////////////////////////////////////////////
//                                                                       //
// Tell Friend v 1.0                                                     //
// --------------------------------------------------------------------- //
// by Graeme Mallam (hide@address.com)                       //
// http://www.smartphponline.com                                         //
//                                                                       //
// Smart PHP Online offers no warranties on this script.                 //
// Smart PHP Online is not responsible for any                           //
// problems caused by installation of the script or use of this script   //
//                                                                       //
// All copyright notices regarding Tell Friend, must remain              //
// intact on the scripts and in the HTML for the scripts.                //
//                                                                       //
// (c) Copyright 2009 Smart PHP Online                                   //
//                                                                       //
// For more info on Tell Friend,                                         //
// see http://www.smartphponline.com/tellfriend.php                      //
//                                                                       //
///////////////////////////////////////////////////////////////////////////




// Number of friend feilds to put on the page
$tellnumber = "3";

// Subject of email
$subject = "I just found a cool site";

// Message sent in the email
$message = "Check this site out i found http://www.smartphponline.com";

// Url to redirect user to once they click submit
$thankyouurl = "http://www.yoursite.com/thankyou.html";





//////////////////////////////////////////////////////////////////////////////////
// DO NOT EDIT ANYTHING BELOW THIS LINE                                         //
//////////////////////////////////////////////////////////////////////////////////


?>
<HTML>
<HEAD>
  <TITLE>Tell Friend v1.0 - Powered by: (http://www.smartphponline.com/tellfriend.php)</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<!--

Powered by: Tell Friend Version 1.0 (http://www.smartphponline.com/tellfriend.php)

-->
<?


if($_POST[submitform] == "Submit") {

$error = "";
$num=0;

while($num < $tellnumber) {
$num++;
$temail = "femail"."$num";
$tname = "fname"."$num";

if($_POST[$tname] OR $_POST[$temail]) {
if(!$_POST[$tname]) {
$error .= "Missing Friends Name,  Friend $num<BR>";
}
if(!$_POST[$temail]) {
$error .= "Missing Friends Email,  Friend $num<BR>";
}
}

if($_POST[$temail]) {
if(!ereg("@",$_POST[$temail])) { $error .= "Invalid Email Address, Friend $num<BR>"; }
if(!ereg("\.",$_POST[$temail])) { $error .= "Invalid Email Address, Friend $num<BR>"; }
}

}

if(!$_POST["name"]) {
$error .= "Missing your name<BR>";
}
if(!ereg("@",$_POST[email])) { $error .= "Invalid Email Address<BR>"; }
if(!ereg("\.",$_POST[email])) { $error .= "Invalid Email Address<BR>"; }

if($error) {
?>
<P><CENTER><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
  <TR>
    <TD WIDTH="100%" BGCOLOR="#004080">
    <TABLE WIDTH="394" BORDER="0" CELLSPACING="1" CELLPADDING="2">
      <TR>
        <TD WIDTH="26%" BGCOLOR="#004080">
        <B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Error</FONT></B></TD>
      </TR>
      <TR>
        <TD WIDTH="26%" BGCOLOR="#ffffff">
        <FONT COLOR="#000000" SIZE="-1" FACE="Verdana"><? echo $error; ?></FONT></TD> 
      </TR>
    </TABLE></TD>
  </TR>
</TABLE></CENTER>
<P><CENTER>&nbsp;</CENTER></P>
<P><CENTER><FONT SIZE="-2" FACE="Verdana"><B>Powered by:</B> <A HREF="http://www.smartphponline.com/tellfriend.php">Tell Friend</A> Version 1.0</FONT></CENTER></P>
</BODY></HTML>
<?
exit();
}


    $extra ="\r\n";
          $headers = "";
          $headers .= "From: $_POST[name] <$_POST[email]>".$extra;
          $headers .= "Reply-To: $_POST[name] <$_POST[email]>".$extra;
          $headers .= "Return-Path: $_POST[name] <$_POST[email]>".$extra;
          $headers .= "Message-ID: <".time()." - $_POST[email]>".$extra;
          $headers .= "X-Mailer: PHP v".phpversion().$extra;
          $headers .= 'MIME-Version: 1.0'.$extra.$extra;

$num=0;

while($num < $tellnumber) {
$num++;
$temail = "femail".$num;
$tname = "fname".$num;
$print_f_name = $_POST[$tname];
$print_f_email = $_POST[$temail];

if($_POST[$temail] AND $_POST[$tname]) {


mail($print_f_email,"$subject","
Hi, $print_f_name

$message

From
$_POST[name]

---------------------
Powerd by Tell Friend v1.0 (http://www.smartphponline.com/tellfriend.php)

",$headers);


}

}

header("Location: $thankyouurl");
exit();


} else {

$num=0;
while($num < $tellnumber) {
$num++;
$theboxes .= " <TR>
        <TD WIDTH=\"49%\" BGCOLOR=\"#ffffff\">
        <P><CENTER><B><FONT COLOR=\"#000000\" SIZE=\"-1\" FACE=\"Verdana\">$num</FONT></B></CENTER></TD>
        <TD WIDTH=\"26%\" BGCOLOR=\"#ffffff\">
        <P><CENTER><INPUT NAME=\"fname$num\" TYPE=\"text\" SIZE=\"25\"></CENTER></TD>
        <TD WIDTH=\"25%\" BGCOLOR=\"#ffffff\">
        <INPUT NAME=\"femail$num\" TYPE=\"text\" SIZE=\"25\">
</TD> 
      </TR>";
}


?>
<P><CENTER><FONT FACE="Verdana"><B>Tell your friend about our site</B></FONT></CENTER></P>
<FORM ACTION="tellfriend.php" METHOD="POST"><P><CENTER><TABLE BORDER="0" CELLSPACING="0" 
CELLPADDING="0">
  <TR>
    <TD WIDTH="100%" BGCOLOR="#004080">
    <TABLE WIDTH="394" BORDER="0" CELLSPACING="1" CELLPADDING="2">
      <TR>
        <TD WIDTH="26%" BGCOLOR="#004080">
        <P><CENTER><B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Your Name</FONT></B></CENTER></TD>
        <TD WIDTH="25%">
        <P><CENTER><B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Your Email</FONT></B></CENTER></TD>
      </TR>
      <TR>
        <TD WIDTH="26%" BGCOLOR="#ffffff">
        <P><CENTER><INPUT NAME="name" TYPE="text" SIZE="25"></CENTER></TD>
        <TD WIDTH="25%" BGCOLOR="#ffffff">
        <INPUT NAME="email" TYPE="text" SIZE="25">
</TD>
      </TR>
    </TABLE></TD>
  </TR>
</TABLE></CENTER></P><P><CENTER><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
  <TR>
    <TD WIDTH="100%" BGCOLOR="#004080">
    <TABLE WIDTH="394" BORDER="0" CELLSPACING="1" CELLPADDING="2">
      <TR>
        <TD WIDTH="49%" BGCOLOR="#004080"></TD>
        <TD WIDTH="26%" BGCOLOR="#004080">
        <P><CENTER><B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Friends name</FONT></B></CENTER></TD>
        <TD WIDTH="25%">
        <P><CENTER><B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Friends email</FONT></B></CENTER></TD> 
      </TR><? echo $theboxes; ?></TABLE></TD>
  </TR>
</TABLE></CENTER></P>
<P><CENTER><INPUT NAME="submitform" TYPE="submit" VALUE="Submit"></CENTER></FORM>
<P><CENTER>&nbsp;</CENTER></P>
<P><CENTER><FONT SIZE="-2" FACE="Verdana"><B>Powered by:</B> <A HREF="http://www.smartphponline.com/tellfriend.php">Tell Friend</A> Version 1.0</FONT></CENTER></P>
</BODY>
</HTML>
<?
exit();

}

?>
Return current item: Tell Friend