Jump to content

how to get a users ip adress...


pemdas21

Recommended Posts

I have an email form setup and I want to have the person's ip address that sends an email through it attached to the message. What hidden element do I add to the page itself, and what do I add to the php script?

Form script=
[code]<FORM name="Mailto" method="POST" action="emails.php" enctype="application/x-www-form-urlencoded">
<INPUT type="hidden" name="redirect" value="http://www.orrita.com/">
<select name="Person" size="1" style="position:absolute;left:168px;top:72px;width:384px;font-family:MS Shell Dlg;z-index:7">
<option selected>Choose a Recipient</option>

<option value="Joe Shmoe">Joe Shmoe</option>
</select>
<INPUT type="text" style="position:absolute;left:192px;top:120px;width:336px;z-index:8" size="42" name="Email" value="Your E-Mail Address">
<INPUT type="text" style="position:absolute;left:168px;top:192px;width:384px;z-index:9" size="48" name="Subject" value="Subject">
<TEXTAREA name="Message" style="position:absolute;left:168px;top:216px;width:384px;height:144px;z-index:10" rows=9 cols=45>Message</TEXTAREA>
<INPUT type="submit" name="" value="Submit" style="position:absolute;left:216px;top:384px;width:75px;height:24px;z-index:11">
<INPUT type="reset" name="" value="Reset" style="position:absolute;left:432px;top:384px;width:75px;height:24px;z-index:12">

</FORM>
[/code]

And the code for the php script:
[code]<%
Dim gv__POST(), gv_mailto, gv_mailbody


If isset(gv__POST("email")) then
email    = $_POST["email"]

If $Person == "Joe Shmoe" then
gv_mailto  = "joeshmoe@whatever.net"
End If




' repeat the above If statement as many times as the persons
$mailsubj  = $HTTP_POST_VARS["Subject"]
$Message  = $HTTP_POST_VARS["Message"]
$mailhead  = "From: " & email & "\n"
gv_mailbody  = "" & Message & "\n"
&  "\n"
&  "Email sent through our Web Mail form\n"
mail(
%>
[/code]
Link to comment
Share on other sites

In vbscript? This is a PHP forum. I'll tell you now, that is neither vbscript or PHP but a hybrid of both.

A users ip is optained in PHP via $_SERVER['REMOTE_ADDR'], in vbscript I believe it is request.server("REMOTE_ADDR").
Link to comment
Share on other sites

sorry... I am new to this type of scripting... Bear with me... I have no idea how to do this. I am sorry that I put this in the wrong section as well. If someone could modify my script to do send the ip address of the person after their email, and then tell me how it works, that would be absolutely awesome! Thanks for the quick response.
Link to comment
Share on other sites

more importantly this forum is not about writing script for you, but nudging you in the right direction.  Thorpe has provided you the variables that hold the user's ip address, for both php and vbscript.  If you cannot figure out how to encorporate a variable into your script, even by looking at the variables already in your script...do I really need to say what comes next in this statement?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.