SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Jan 2014
    Location
    Washington, DC
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Recommend Us Script

    The Recommend Us Script does not work with Google Chrome, Internet Explorer or Firefox. Could someone take a look at it and see if the error can be fixed. I am assuming there is a minor typo some where in the code.

    Look here: sitepoint.com/forums/showthread.php?459783-Recommend-Us-Script

    Thank you.

    All three web browers show this:

    Code:
    ' . $message . '
    
    '; } $themessage = '
    
    Hello,
    
    Your friend ' . $yourname . ' has sent you an invitation to visit our site.
    
    Please visit our site at: http://www.YourURL.com
    
    Your friend also attached a message, which was:
    
    ' . $come . '
    
    Very truly yours,
    YourURL.com
    -------------------------------------
    
    Note:
    ' . $yourname . ' IP address is ' . $address . '.
    '; $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 = 'Thank You For Recommending YourURL To Your Friends!
    You can use the form again to recommend us to your other friends.
    '; } ?>
    
    Recommend YourURL.com To Your Friends & Partners:
    
    Your Name:
    
    Your Email Address:
    
    Your Friend's Email Address:
    
    Your Message:
    
    www.YourURL.com
    Last edited by Mittineague; Jan 3, 2014 at 23:07.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,255
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    Hi Mike63740, welcome to the forums

    The code
    PHP Code:
    <?

    //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>
    is using "short open tag" http://www.php.net/manual/en/ini.cor...short-open-tag

    You can either change the setting in the php.ini file
    -or-
    change <? to <?php

    Tough decision huh?

  3. #3
    SitePoint Member
    Join Date
    Jan 2014
    Location
    Washington, DC
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I miss understood the forum. I thought the Recommend Us Script could simply be used by just inserting it into a Html Page. All I know about codes is coping and pasting.

    Is there any other scripts or codes that can be used by someone with little or no knowledge?

    Thank you.

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,255
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    The forums are a place for discussion, not a code repository.

    That said, though a lot of code is bits and pieces or uses "generic" naming, you should be able to find a lot of useful examples. If you get stuck you can always ask, newbies are welcome here and many will be happy to help you learn.

    Did you try changing the "<?" to "<?php" in the above code? Surely adding 3 additional characters isn't beyond your ability

  5. #5
    SitePoint Member
    Join Date
    Jan 2014
    Location
    Washington, DC
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I tried, but I get the same Results.

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,255
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    The file name has the ".php" extension?
    Are you viewing it as a file in your browser instead of from a server running PHP?

  7. #7
    SitePoint Member
    Join Date
    Jan 2014
    Location
    Washington, DC
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I using a web page with the .html extension. Possibly this is the problem.

  8. #8
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,255
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    Yes, unless you have the server set up to send requests for HTML files through the PHP engine (a bit more involved than simply giving them the ".php" extension) the PHP code won't get processed.

  9. #9
    SitePoint Member
    Join Date
    Jan 2014
    Location
    Washington, DC
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The server is set up to send requests for HTML files through the PHP engine. Using a web page with the .html extension was the problem.

    I created a new web page with the .php extension and inserted the Recommend Us Script as given here: sitepoint.com/forums/showthread.php?459783-Recommend-Us-Script

    The script works wonderful just the way it is. The main problem was lack of knowledge on my part.

    Mittineague, thank you very much for leading me in the right direction.
    Last edited by Mittineague; Jan 4, 2014 at 20:41.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •