Recommend Us Script

Discussion in 'PHP' started by Vahid, Feb 16, 2007.

  1. #1
    Recommend us script is one of the effective viral marketing tools. It is highly "recommended" to have recommend us page on your website and let visitors to refer others to your website.

    Here is the recommend us script I have created. You just need to replace the YourURL with your own domain name. Enjoy!

    
    
    <?
    
    //This script is creadted by Vahid Chaychi at http://www.weboma.com
    //You need to customize it for your website. The only thing you need
    //to do is replacing the YourURL.com with your website URL.
    
    if($_SERVER['HTTP_REFERRER'] == NULL){
    	$sitename = 'http://www.YourURL.com';
    } else {
    	$sitename = $_SERVER['HTTP_REFERRER'];
    }
    
    if($_POST['email']){
    $address = $_SERVER['REMOTE_ADDR'];
    $yourname = $_POST['yourname'];
    $youremail = $_POST['youremail'];
    $email = $_POST['email'];
    
    $message = $_POST['message'];
    
    if($message != 'NA'){
    	$come = '<p align="justify"><b> ' . $message . '
    </font> </b></p>';
    }
    
    	$themessage = '
            <p>Hello,</p>
    	<p align="justify">Your friend <b><u>' . $yourname . '</u></b>
     has sent you an invitation to visit our site.</p>
    	<p align="justify">Please visit our site at:
     <a href="' . $sitename . ' " target="_blank">
    http://www.YourURL.com</a></p>
    	<p align="justify">Your friend also attached a
     message, which was:</p>
    <hr color="#FF0000" width="80%" align="left" size="1"><p>
    <b>' . $come . '</b></p>
    <hr color="#FF0000" width="80%" align="left" size="1">
    	<p>Very truly yours,<br>YourURL.com<br>
    -------------------------------------</p>
            <p><b>Note:</b><br>
            ' . $yourname . ' IP address is <u>' . $address . '</u>.</p>
    	';
    
    	$subj= "A Message From: " . $yourname . " "; 
    	$header = "Return-Path: " . $email . "\r\n"; 
    	$header .= "From: $yourname <" . $youremail . ">\r\n"; 
    	$header .= "Content-Type: text/html; charset=iso-8859-1;\n\n\r\n"; 
    	
    	@mail ($email,"$subj",$themessage,$header);
    $message2 = '<font size="2" face="Arial"><b>Thank You For Recommending
     YourURL To Your Friends!</b></font><br>
                 <font size="2" face="Arial">You can use the
     form again to recommend
     us to your other friends.</font><br>
    
    ';
    
    }
    ?>
    <html>
    <head>
    <title>Recommend YourURL.com To Your Friends</title>
    </head>
    <body topmargin="0" leftmargin="0">
    <br><br><br>
    <form action="<? echo $_SERVER['PHP_SELF'];?>" method="post"
     name="tellfrnd" id="tellfrnd" onSubmit="return validatetell(this)">
    	 <p style="margin-left: 110">
    	  <?
         if($message2 != NULL){
    	 echo $message2; } ?>
    	 </p>
    	 <hr color="#FF0000" size="1" width="90%">
      <div align="center">
        <center>
      <table width="723" border="0" cellpadding="2" height="1">
        <tr> 
          <td width="715" height="22" colspan="3">
          <p style="margin-left: 5">
          <font size="4" color="#0683FF"><b>Recommend YourURL.com To
     Your Friends &amp; Partners:</b></font></td>
        </tr>
        <tr> 
          <td width="202" height="22">
          <p align="right"><b><font face="Arial" size="2">
    Your Name:</font></b></td>
          <td width="513" height="22" colspan="2">
          <input name="yourname" type="text" id="yourname" size="28"></td>
        </tr>
        <tr>
          <td width="202" height="1" valign="middle">
          <p align="right"><b><font face="Arial" size="2">Your Email 
          Address:</font></b></td>
          <td width="513" height="1" colspan="2">
          <input name="youremail" type="text" id="email" size="28"></td>
        </tr>
        <tr> 
          <td width="202" height="1" valign="middle">
          <p align="right"><b><font face="Arial" size="2">
    Your Friend's Email 
          Address:</font></b></td>
          <td width="513" height="1" colspan="2">
          <input name="email" type="text" id="email" size="28"></td>
        </tr>
        <tr> 
          <td width="202" height="1" valign="top">
          <p align="right"><b><font face="Arial" size="2">
    Your Message:</font></b></td>
          <td width="513" height="1" valign="top" colspan="2">
          <textarea name="message" id="message" rows="5" cols="42">
    </textarea></td>
        </tr>
        <tr> 
          <td height="24" width="202">
          <p align="center">&nbsp;</td>
          <td width="351" height="24">
          <p align="center">
              <input name="Submit" type="submit" id="Submit"
     style="background-color:#FFFFFF;font-weight:bold;
    color:#0065CE;font-size:8pt; font-family:Arial"
     value="Submit The Form">
    </strong></font></td>
          <td width="157" height="24">&nbsp;</td>
        </tr>
      </table>
        </center>
      </div>
      </form>
    
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p align="center"><b><font size="1" face="Arial">
    <a target="_blank" href="http://www.YourURL.com/">
    www.YourURL.com</a></font></b></p>
    
    </body>
    </html>
    <script>
    function validatetell(object){
    var valid = true;
    if(object.yourname.value == 0){
    	alert("Please Enter Your Name!");
    	object.yourname.focus();
    	return false;
    }
    if (object.email.value.indexOf("@")==-1 ||
     object.email.value.indexOf(".")==-1 ||
      object.email.value.indexOf(" ")!=-1 || object.email.value.length<6){
       	alert("Please Enter At Least One Valid Email!");
    	object.email.focus();
    	return false;
    }
    if(object.message.value == 0){
    	object.message.value = 'NA';
    }
    return valid;
    }
    
    </script>
    
    
    PHP:
     
    Vahid, Feb 16, 2007 IP
  2. kdemonte

    kdemonte Peon

    Messages:
    166
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm not a coder. How exactly does it work. Does this pull up a tell a friend type of box layout or just an email to send the site link to?
     
    kdemonte, Feb 16, 2007 IP