/    Sign up×
Community /Pin to ProfileBookmark

IP address only saves sometimes

I have a form where I need to know a persons ip address, and it also displays for them.

for the function i have (in the body):
var ipad = ‘<!–#echo var=”REMOTE_ADDR”–>’
function ipval() {
document.emailform.ip.value=ipad;
}

and then in the form I have:
<input name=”ip” type=text readonly=”true”>

and when I get the form submissions, only about half the time do I get the IP address. is this incorrect or what’s the deal, anyone know?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@MstrBobOct 24.2005 — Why rely on Javscript? Not everyone has javascript enabled. Why not echo it directly?

[code=html]
<input name="ip" type="text" value="<!--#echo var="REMOTE_ADDR"-->" readonly="true">
[/code]
Copy linkTweet thisAlerts:
@scythetleppoauthorOct 24.2005 — Why rely on Javscript? Not everyone has javascript enabled. Why not echo it directly?

[code=html]
<input name="ip" type="text" value="<!--#echo var="REMOTE_ADDR"-->" readonly="true">
[/code]
[/QUOTE]


for real? can I use it as is, or do I have to change the " 's to ' 's ?
Copy linkTweet thisAlerts:
@UltimaterOct 24.2005 — Even that method is flawed because the user can use a bookmarklet.
<i>
</i>javascript:void(function(){var e=document.getElementsByName("ip")[0];e.value="99.99.99.99";}())


You'd best go server side so the user can't mess with you. PHP is a good choice.
Copy linkTweet thisAlerts:
@UltimaterOct 24.2005 — for real? can I use it as is, or do I have to change the " 's to ' 's ?[/quote]
The server side include
value="&lt;!--#echo var="REMOTE_ADDR"--&gt;" works as expected, no need to change all the double quotes into single. It works because each instance of
&lt;!--#echo var="REMOTE_ADDR"--&gt; on the server is replaced with the user's IP address and by the time it reaches the client, for example, it would read:
value="24.55.33.24"

So there is no issue of having double quotes nested-within double quotes in the HTML.
Copy linkTweet thisAlerts:
@scythetleppoauthorOct 24.2005 — Even that method is flawed because the user can use a bookmarklet.
<i>
</i>javascript:void(function(){var e=document.getElementsByName("ip")[0];e.value="99.99.99.99";}())


You'd best go server side so the user can't mess with you. PHP is a good choice.[/QUOTE]



I understand I think...

Is that clip right there what I need? what is that syntax?


edit: also I can't use php because Im using yahoo's cheapest hosting, that doesn't allow php. what's the best javascript or html version?
Copy linkTweet thisAlerts:
@UltimaterOct 24.2005 — Can't expect security without some money. Get yourself a domain, you won't regret it. Otherwise, you can use the code MstrBob gave you. The Bookmarklet I gave you is something that any user can type in their address bar to mess with your site.

For example, this bookmarklet will turn my Name "Ultimater" into bold italic text (of this post):
<i>
</i>javascript:void(function(){var e=document.getElementById("postmenu_452913");e.getElementsByTagName("a")[0].innerHTML="&lt;Strong&gt;&lt;i&gt;Ultimater&lt;/i&gt;&lt;/strong&gt;"}())

Oh. look at that, I'm an Administrator now, baby! ?
×

Success!

Help @scythetleppo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...