Solved

Tracking IP etc on form

Posted on 2002-03-22
2
133 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
2 Comments
 
LVL 5

Accepted Solution

by:
Sapa earned 50 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Which version of C should I use when Perl is too slow? 13 181
ppm conversion to curl on a module install 8 82
Writing a parser for java language 4 79
combine multiple lines 2 60
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 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