Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - How to include sender's IP in a "contact us" form
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to include sender's IP in a "contact us" form

 Post Reply Post Reply
Author
iSec View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 February 2005
Status: Offline
Points: 1140
Post Options Post Options   Thanks (0) Thanks(0)   Quote iSec Quote  Post ReplyReply Direct Link To This Post Topic: How to include sender's IP in a "contact us" form
    Posted: 31 July 2006 at 8:46am

How do I include the IP address of the person that uses a "contact us" form ...

P.S. The form is ASP-based... created by webwiz guide..and uses JMail component.
"When it gets dark enough, you can see the stars"
-Charles A. Beard
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2006 at 9:10am
visit this page.

all you do is:
Request.ServerVariables("REMOTE_ADDR")


S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
iSec View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 February 2005
Status: Offline
Points: 1140
Post Options Post Options   Thanks (0) Thanks(0)   Quote iSec Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2006 at 9:41am
I placed that line of code within the script and tried to sent a test message...but it didn't deliver the ip address within the email message.
"When it gets dark enough, you can see the stars"
-Charles A. Beard
Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bluefrog Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2006 at 11:42am
I've written some tutorials on this kind of stuff. Check out the one on HTTP headers. It has code samples. The samples there will give you all the headers available and you can just plug them in then.

But make sure that you add it to the email body properly.


Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post Posted: 01 August 2006 at 10:07am
i just tested the code i gave you, it works perfectly fine for me.

could you paste up the code for your script?
S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
Tegwin View Drop Down
Senior Member
Senior Member


Joined: 03 September 2003
Location: United Kingdom
Status: Offline
Points: 430
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tegwin Quote  Post ReplyReply Direct Link To This Post Posted: 02 August 2006 at 11:44pm
I have a feedback form on my website using exactly this. It sends me the IP Address in an email form. I have pasted the code on here for you which I modified from some code I found on the internet.

First I declared the variable called strIP 

' Get the Users IP address
strIP = request.ServerVariables("REMOTE_ADDR")

 Then I use the JMAIL Component to send the email ... See the RED bit for where I display the IP Address in my email


Set JMail = Server.CreateObject("JMail.SMTPMail")


JMail.ServerAddress = "blah.blah.com" 'Change this line to the address of your email server.
JMail.AddRecipient "blah@blah.com" ' change this line to the email address to receive the mail at

JMail.Sender = t2   ' This populates the Sender of the email with the persons email address entered in the form
JMail.Subject = "Web Site Feedback"  'This can be changed to anything you want

JMail.HTMLBody = "<B>FROM : </B>" & t1 & "<BR>" & "<B>Email: </B>" & t2 & "<BR>" & "<B>Subject: </B>" & Subj &  "<BR>" & "<B>Tel: </B>" & Tel & "<BR>" & "<B>Comments: </B>" & st & "<BR>" & "<B>IPAddress: </B>" & strIP & "<BR>" & "<BR>" & "<HR>" & "<BR>" & "This email was sent on :" & Time1 & "&nbsp;&nbsp;" & Date1 ' This is the bit that actually formats the email so that it readable


JMail.Execute 'Execute the email
Set JMail = Nothing ' Reset the JMAIL to nothing

Hope this helps you.




Back to Top
iSec View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 February 2005
Status: Offline
Points: 1140
Post Options Post Options   Thanks (0) Thanks(0)   Quote iSec Quote  Post ReplyReply Direct Link To This Post Posted: 03 August 2006 at 10:47pm
Hello all...
Sorry about the late reply... it was a busy week..
Bluefrog...I tried that but no luck,.... I know i;m doing something wrong but i don't know where...
 
Tegwin... the form I use is a little different than yours... I declared the variable and then included the code with the rest of other code and it still, didn't deliver the ip address yet...
 
Scotty...here is the code I use on my site... the part in red is from what Tegwin advised...
 

<%
'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser
Response.Buffer = True
'Dimension variables
Dim strBody    'Holds the body of the e-mail
Dim objJMail    'Holds the mail server object
Dim strMyEmailAddress   'Holds your e-mail address
Dim strSMTPServerAddress 'Holds the SMTP Server address
Dim strCCEmailAddress  'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
Dim strBCCEmailAddress  'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
Dim strReturnEmailAddress 'Holds the return e-mail address of the user
Dim strIP = request.ServerVariables("REMOTE_ADDR") 'Get the Users IP address

'----------------- Place your e-mail address in the following sting ---------------------------------
strMyEmailAddress = "my email address"
'---------- Place the address of the SMTP server you are using in the following sting ---------------
strSMTPServerAddress = "server addresss..."
'-------------------- Place Carbon Copy e-mail address in the following sting ------------------------
strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail
'-------------------- Place Blind Copy e-mail address in the following sting -------------------------
strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail
'-----------------------------------------------------------------------------------------------------
'Read in the users e-mail address
strReturnEmailAddress = Request.Form("email")
'Get the IP address of the sender
Request.ServerVariables("REMOTE_ADDR")
'Initialse strBody string with the body of the e-mail
strBody = "<h2>Website Inquiry</h2>"
strBody = strBody & "<br><b>Name: </b>" & Request.Form("firstName") & " " & Request.Form("lastName")
strBody = strBody & "<br><br><b>Address: -</b>"
If (Request.Form("street1")) > "" Then
 strBody = strBody & "<br>  " & Request.Form("street1")
End If
If (Request.Form("street2")) > "" Then
 strBody = strBody & "<br>  " & Request.Form("street2")
End If
If (Request.Form("town")) > "" Then
 strBody = strBody & "<br>  " & Request.Form("town")
End If
If (Request.Form("county")) > "" Then
 strBody = strBody & "<br>  " & Request.Form("county")
End If
If (Request.Form("country")) > "--- Choose One ---" Then
 strBody = strBody & "<br>  " & Request.Form("country")
End IF
If (Request.Form("postCode")) > "" Then
 strBody = strBody & "<br>  " & Request.Form("postCode")
End If
strBody = strBody & "<br><br><b>Telephone: </b>" & Request.Form("tel")
strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
strBody = strBody & "<br><br><b>Enquiry: - </b><br>" & Replace(Request.Form("enquiry"), vbCrLf, "<br>")

'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then
 
 'Set the return e-mail address to your own
 strReturnEmailAddress = strMyEmailAddress
End If 

'Send the e-mail
'Create the e-mail server object
Set objJMail = Server.CreateObject("JMail.SMTPMail")
'Out going SMTP mail server address
objJMail.ServerAddress = strSMTPServerAddress
'Senders email address
objJMail.Sender = strReturnEmailAddress
'Senders name
objJMail.SenderName = Request.Form("firstName") & " " & Request.Form("lastName")
'Who the email is sent to
objJMail.AddRecipient strMyEmailAddress
'Who the carbon copies are sent to
objJMail.AddRecipientCC strCCEmailAddress
'Who the blind copies are sent to
objJMail.AddRecipientBCC strBCCEmailAddress
'Set the subject of the e-mail
objJMail.Subject = "Enquiry sent from enquiry form on website"

'Set the main body of the e-mail (HTML format)
objJMail.HTMLBody = strBody
'Set the main body of the e-mail (Plain Text format)
'objJMail.Body = strBody
'Importance of the e-mail ( 1 - highest priority, 3 - normal, 5 - lowest)
objJMail.Priority = 3
'Send the e-mail
objJMail.Execute
 
'Close the server object
Set objJMail = Nothing
%>


Edited by Info_Tech - 03 August 2006 at 10:54pm
"When it gets dark enough, you can see the stars"
-Charles A. Beard
Back to Top
Tegwin View Drop Down
Senior Member
Senior Member


Joined: 03 September 2003
Location: United Kingdom
Status: Offline
Points: 430
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tegwin Quote  Post ReplyReply Direct Link To This Post Posted: 04 August 2006 at 12:15am
Scotty,
You have only declared the variable you have not displayed it.  strIP is the variable that holds the IP address, so you will need to have something like this.  You need to add the strIP to the StrBody somewhere .. like this


strBody = strBody & "<br><br><b>IP Address  - & strIP</b>"



Have a look at my code again, you will see this is what I have done.
Also you will need to remove the line

'Get the IP address of the sender
Request.ServerVariables("REMOTE_ADDR")


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.