Jump to content

How to get the ip address from an Html form?


Go to solution Solved by Barand,

Recommended Posts

so i've been trying to figure this out for a long time already, but still don't get it how does this "get_ip" thing turns out inside the email in the end?

https://stackoverflow.com/questions/51067389/how-to-get-ip-address-from-html-form-using-php

and how can you use the "<?php echo $ip ?>" code inside an html form in the first place if it is only html and not even php at all? (aka the ¤value="<?php echo $ip;?>"¤ part doesnt even work at all and only displays the same exact code instead of the ip...)

plus where should it display the "<script>var ip = "<?php echo $ip;?>"; </script>" part when i can only insert scripts into the <head> part and not in the <body> section?

Edited by jenny5
  • Solution

Most servers are configured so that files with names ending with ".php" are processed by the PHP preprocessor. Unless your server is specifically configured to do so, ".html" files will not be processed and any php code is treated a text.

i basically have the main form page as .html atm, but should i convert it to php then somehow to get that "value= echo" part to work?

currently i have the php part in the 'action' part like this:
<form action="getdata.php" method="post" name="name">

ok, but now the charset wnet crazy a bit and "charset=ISO-8859-1" doesn't seem to work anymore...

and should i start the newly renamed file with some php code now? it's like this atm:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

(plus the ip box is completely empty now)

Edited by jenny5

ok, now i finally got it to work by just taking the "ip" form value via this code:
https://www.codegrepper.com/code-examples/php/how+to+get+ip+address+of+client+using+php

but now there is that charset issue lol
(plus it seems to add my own email address to the end of the email every time - i have only set it to be the 'send to' address, nothing else)

Edited by jenny5

lol.. now i fixed the charset issue with this (except in the actual email title in the inbox):
<?php header('Content-type: text/html; charset=iso-8859-1'); ?>
<!DOCTYPE HTML>
<head>
<meta name="x" content="y" />

so now the only issue is that own email address at the end of the email...
 

Edited by jenny5
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.