0

メールへの紹介リンクを表示したい。これは私がこれまでに得たものです。

<form method="POST" action="javascript:" name="form">
            <br /><label> <input type="text" name="text" id="text" placeholder="Name" value="" /> </label>
            <br /><label> <input type="text" name="email" id="email" placeholder="Email" value="" /> </label>
            <br /><label> <input type="text" name="phone" id="phone" placeholder="Phone" value="" /> </label>
            <br /><label> <input type="text" name="company" id="company" placeholder="Company" value="" /> </label> 
            <br /><label> <textarea name="textarea" id="textarea" placeholder="Message" rows="3" value="0" /></textarea> </label>
            <br /><label> <input type="text" name="referrer" id="WelcomePlaceHolder" placeholder="Referrer" value="" style="display: none;"/></textarea> </label>
        <br />
            <br /><label> <input class="homebotton" type="button" name="button" id="button" placeholder="button" value="Send" /> </label>
         </form>

メールに送信されたフォーム:

$message .= '<tr><td>Name : </td><td>' . $_REQUEST['text'] . '</td><tr>';
    $message .= '<tr><td>Email : </td><td>' . $_REQUEST['email'] . '</td></tr>';
    $message .= '<tr><td>Phone : </td><td>' . $_REQUEST['phone'] . '</td></tr>';
    $message .= '<tr><td>Company : </td><td>' . $_REQUEST['company'] . '</td></tr>';
    $message .= '<tr><td>Message : </td><td>' . $_REQUEST['textarea'] . '</td></tr>';
    $message .= '<tr><td>Referral Site : </td><td>' . $_REQUEST['referrer'] . '</td></tr>'; 

リファラーリンクを取得するためのJavascript。

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
//Add urls regular expressions and your message(any HTML Code) to the array
var msgs = [
//null url : to show a message for direct traffic (no referer, some one who remember your site url!)
{'url':null,                           'msg':'I am glad you remember my site URL, enjoy your stay'}
//My url! : show message for referrals from your own site or null so you do not annoy them
,{'url':/^http:\/\/(\w+\.)?moretechtips\.net/,    'msg':null}
//Other urls
,{'url':/^http:\/\/(\w+\.)?google\.com/,      'msg':'Welcome googler, Hope you will find what you looking for'}
,{'url':/^http:\/\/(\w+\.)?dzone\.com/,         'msg':'Welcome fellow dzone reader, if you like it please vote it up'}
,{'url':/^http:\/\/(\w+\.)?digg\.com/,         'msg':'Welcome digger, if you like it please digg it'}
,{'url':/^http:\/\/(\w+\.)?propeller\.com/,      'msg':'Welcome propeller user, hope you will like it here'}
//generic pattern: to show generic message for referrers that you did not specify one for
//You must keep it at the end of the list as it will match any non empty referrer
,{'url':/^http:\/\//,               'msg':'Hello their.. Hope you will find what you looking for'}
];
function DetectReferrer(){
   var div = $('#WelcomePlaceHolder');
   //if Div was not placed means , not to show message
   if (!div.length) return;
   var ref = document.referrer.toLowerCase();
   var msg = findMatch(ref);
   // if not null msg found
   if(msg) {
      //Add Close Button and Show up message
      div.html( '<a href="javascript:void(0)" class="CloseButton">X</a>' + msg).show('slow',function(){
         //Hide On click close Button
         $('.CloseButton',div).click(function(){ div.hide() })
      });
   }
}
function findMatch(ref) {
   for(var i=0; i<msgs.length; i++)
      if( ( ref=='' && msgs[i].url==null) || (ref>'' && ref.match(msgs[i].url) ) )
         return msgs[i].msg;
   return null;
}

// Call the Referrer Detector function on document ready
$(DetectReferrer);
</script>

このスクリプトは機能します。メールに送信された紹介リンクを表示しようとしましたが、空です。紹介リンクは空です。私は理にかなっていると思います。

4

1 に答える 1

0

msgsこれにより、電子メールのテーブルからメッセージが送信されます。

if(msg) {
   //Add Close Button and Show up message
   div.html( '<a href="javascript:void(0)" class="CloseButton">X</a>' + msg).show('slow',function(){
      //Hide On click close Button
      $('.CloseButton',div).click(function(){ div.hide() })
   });
   // Include message in form data
   div.val(msg);
}

テーブルにあるかどうかに関係なく、リファラーURLだけが必要な場合は、次のようにします。

div.val(ref);

if (msg)

これをPHPスクリプトに送信するには、フォームフィールドを次のように変更する必要があります。

<input type="hidden" name="referrer" id="WelcomePlaceHolder" placeholder="Referrer" value=""/>

display: noneサーバーに送信されていないフォームフィールドは、そのためのものtype="hidden"です。

于 2013-01-17T01:52:18.450 に答える