?
Solved

Tracking IP etc on form

Posted on 2002-03-22
2
Medium Priority
?
139 Views
Last Modified: 2010-03-05
Please see this question:

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?qid=20274914&jsessionid=2593911016807936864

I would like the ability to track the IP address on the following form.  I am slightly modifying the address of my client.

It's on a NT server.

Here's the perl.  The HTML follows after that.  I am only offering 50 points because I am starting to get a bit low!  Hopefully the solution is ver simple.

If it is also easy, I would like to get any other information such as their browser type, refering domain, etc -- anything that is as easily obtainable as their IP

===============PERL SCRIPT FOLLOWS ==============
$|++;
use Net::SMTP;
use CGI;
$q = new CGI;

$ecxfolks='johndoe@blah.com>, johnsmith@blah.com>';
$toddemail='thatch@blah.com>';
$message="This is a Thank you note\nThis is the 2nd line of the the message.";
$user_subject='Thank You!!';

foreach ($q->param){
      $$_=$q->param($_);

      next if /^affiliate_email$/;
      $$_=~ s/^\s+//g;
      $$_=~ s/\s+$//g;
}

@new_from=split(/,\s/,join(', ',$ecxfolks)); ## NOTE the , inside the single quotes

if (!($to)){
      print "Content-type: text/html\n\n";
      print "Please go back and enter your email address.BR>\n";
      exit;
}

if (!($name)){
      print "Content-type: text/html\n\n";
      print "Please go back and enter your name.BR>\n";
      exit;
}

foreach $new_from (@new_from){
      $smtp = Net::SMTP->new('localhost'); # connect to an SMTP server
      $smtp->mail($to);      ##      use the affiliate address here
      $smtp->to($new_from);     ##     recipients address. Use new_from, not from
      $smtp->data();
      $smtp->datasend("To: ".$new_from."\n");
      $smtp->datasend("Subject: ".$affiliate_subject."\n");
      $smtp->datasend("\n");
        $smtp->datasend("Subject : $affiliate_subject\n");
      $smtp->datasend("Name : $name\n");
      $smtp->datasend("Email : $to\n");
      $smtp->datasend("Home phone : $homephone\n");
      $smtp->datasend("Work phone  : $workphone\n");
      $smtp->datasend("Comments : $comments\n");
      $smtp->dataend();                   # Finish sending the mail
      
      ##  Close the connection
      $smtp->quit;
}


##      Redirect to the Thank you page.
print "Location: https://www.blah.com/html/content/response2.shtml\n\n";

==================HTML CODE ========================
html>
head>


body bgcolor="#FFFFFF" text="#000000">
table border="0" cellpadding="0" cellspacing="0">
  tr valign="top">
    td>
      div align="center">font face=Arial size=+1 color=#007b79>b>i>Form/i>/b>/font>
      /div>
      div align="right">/div>
      div align="center">/div>
    /td>
  /tr>
  tr valign="top">
    td>
      form method="POST" action="http://www.blah.com/cgi-bin/rowby-cj-new4.plx">
        input type=HIDDEN name="affiliate_subject" value="Form Application">
       

        table cellspacing=5 cellpadding=0 border=0 width="100%">
          !-- BEGIN FORM FIELDS -->
          tr>
            td align=center valign=top  bgcolor="#FFFFFF" height="28" bordercolor="#006666">
              table width="100%" border="1" cellpadding="0" bordercolor="#006666">
                tr>
                  td height="2">
                    table height=100% width=100% cellpadding=2 cellspacing=0 align="center">
                      tr>
                        td align=right valign=center colspan="4" height="19">
                          div align="center">/div>
                        /td>
                      /tr>
                      tr>
                        td align=right valign=center width="24%">font size=-2 face="Arial, Helvetica">nobr>b>
                          NAME/b>/font>/td>
                        td align=left valign=center width="23%">
                          input type="text" name="name" size="25">
                        /td>
                        td align=right valign=center width="10%">font size=-2 face="Arial, Helvetica">nobr>b>HOME
                          PHONE/b>/font>/td>
                        td align=left valign=center width="43%">nobr>
                          input type="text" name="homephone" size="25">
                        /td>
                      /tr>
                      tr>
                        td align=right valign=center width="24%">font size=-2 face="Arial, Helvetica">b>E-MAIL/b>/font>/td>
                        td align=left valign=center width="23%">
                          input type="text" name="to" size="25">
                        /td>
                        td align=right valign=center width="10%">font size=-2 face="Arial, Helvetica">b>WORK
                          PHONE/b>/font>/td>
                        td align=left valign=center width="43%">
                          input type="text" name="workphone" size="25">
                        /td>
                      /tr>
                      tr>
                        td align=right valign=center colspan="4">font size=-2 face="Arial, Helvetica">nobr>/font>
                          div align="center">font size=-2 face="Arial, Helvetica">b>Comments:

                            textarea name="comments" rows="2" cols="35">/textarea>
                            /b>nobr>/font>/div>
                          nobr> /td>
                      /tr>
                      tr valign="top">
                        td align=right colspan="4">
                          div align="center">
                            input type="image" src="image.gif" width="X" height="X"name="Submit" value="Submit">
                          /div>
                        /td>
                      /tr>
                    /table>
                  /td>
                /tr>
              /table>
            /td>
          /tr>
          !-- END FORM FIELDS -->
        /table>
      /form>
    /td>
  /tr>
  tr valign="top">
    td>  /td>
  /tr>
/table>
/body>
/html>

0
Comment
Question by:Rowby Goren
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
Sapa earned 200 total points
ID: 6888857
Just add in you script, after line:

$smtp->datasend("Work phone  : $workphone\n");

follow lines:

$smtp->datasend("Referer     : " . $q->referer . "\n");
$smtp->datasend("Remote Host : " . $q->remote_host . "\n");
$smtp->datasend("User Agent  : " . $q->user_agent . "\n");

0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 6891671
Thank You Sapa.  It was exactly what I needed.

Rowby
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question