dqrq93879 2014-04-03 14:50
浏览 50

javascript从联系表单获取访问者的上一个网址

I want to track my prospects from which URL(like fb, g+ or mailer) they have visited my website.This is all is for understanding visitor for better digital marketing.

My Fiddle: http://jsfiddle.net/dSp4g/

Please help me with code as below

Thanks in advance

HTML

<div class="form-group">
<label for="exampleInputEmail">Full name</label>
<input type="text" class="form-control " id="exampleInputName" placeholder="Enter your full name" style="color:#000 !important;">
 </div>

<div class="form-group">
<input type="hidden" class="form-control " id="sourcecode">
</div>                                          

<div class="form-group last">
<button class="mailbtn">Submit</button>
</div>

JS

$('.mailbtn').live('click',function(){

            name = $('#exampleInputName').val();

            sc = $('#sourcecode').val();

            $(document).ready(function() { 
                if (sourcecode = $.parsequery().s) 
                    {
                        $("#source").val(sourcecode); }
             });


            $.ajax({
            type: "POST",
            async : false,
            url: "mail.php",
                data: { name:name, sourcecode:sc}
            })

            .done(function( msg ) {
            $('.mail_middle').html('');
            $('.mail_middle').html('We will call you to confirm your delivery address.Thank you.');
            return false;

            });



    });

mail.php

<?php
$to =  array("my_email1","my_email2");
$message .= "<table border='1'>";
$message .= "<tr><td>Name    </td><td>".$_POST['name']."</td></tr>";
$message .= "<tr><td>Source   </td><td>".$_POST['sc']."</td></tr>";
$message .= "</table>";

$headers = "MIME-Version: 1.0
"; 

$headers .= "Content-type: text/html; charset=utf-8
"; 

$headers .=  'from: '.$from .'' . "
" .

            'Reply-To: '.$from.'' . "
" .

            'X-Mailer: PHP/' . phpversion();
foreach($to as $row)
{
   mail($row,$subject,$message,$headers);
}

echo "Mail Sent.";
die;
?>
  • 写回答

2条回答 默认 最新

  • dpoppu4300 2014-04-03 15:00
    关注

    Change $_POST['sc']

    $message .= "<tr><td>Source   </td><td>".$_POST['sc']."</td></tr>";
    

    to $_POST['sourcecode']

    $message .= "<tr><td>Source   </td><td>".$_POST['sourcecode']."</td></tr>";
    

    as sourcecode is the name (wheresc is the value)

    data: { name:name, sourcecode:sc}
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料