jenny5 Posted October 2, 2020 Share Posted October 2, 2020 (edited) 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 October 2, 2020 by jenny5 Quote Link to comment https://forums.phpfreaks.com/topic/311557-how-to-get-the-ip-address-from-an-html-form/ Share on other sites More sharing options...
Solution Barand Posted October 2, 2020 Solution Share Posted October 2, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/311557-how-to-get-the-ip-address-from-an-html-form/#findComment-1581695 Share on other sites More sharing options...
jenny5 Posted October 2, 2020 Author Share Posted October 2, 2020 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"> Quote Link to comment https://forums.phpfreaks.com/topic/311557-how-to-get-the-ip-address-from-an-html-form/#findComment-1581696 Share on other sites More sharing options...
Barand Posted October 2, 2020 Share Posted October 2, 2020 1 minute ago, jenny5 said: but should i convert it to php then somehow to get that "value= echo" part to work? Yes, change the file name from xxx.html to xxx.php. Quote Link to comment https://forums.phpfreaks.com/topic/311557-how-to-get-the-ip-address-from-an-html-form/#findComment-1581697 Share on other sites More sharing options...
jenny5 Posted October 2, 2020 Author Share Posted October 2, 2020 (edited) 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 October 2, 2020 by jenny5 Quote Link to comment https://forums.phpfreaks.com/topic/311557-how-to-get-the-ip-address-from-an-html-form/#findComment-1581698 Share on other sites More sharing options...
jenny5 Posted October 2, 2020 Author Share Posted October 2, 2020 (edited) 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 October 2, 2020 by jenny5 Quote Link to comment https://forums.phpfreaks.com/topic/311557-how-to-get-the-ip-address-from-an-html-form/#findComment-1581699 Share on other sites More sharing options...
jenny5 Posted October 2, 2020 Author Share Posted October 2, 2020 (edited) 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 October 2, 2020 by jenny5 Quote Link to comment https://forums.phpfreaks.com/topic/311557-how-to-get-the-ip-address-from-an-html-form/#findComment-1581700 Share on other sites More sharing options...
gizmola Posted October 3, 2020 Share Posted October 3, 2020 Yes, well we would need to actually see your code if you want help. Quote Link to comment https://forums.phpfreaks.com/topic/311557-how-to-get-the-ip-address-from-an-html-form/#findComment-1581710 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.