I have the line of code below in my contact form with the intention of grabbing the IP address of my visitors via the form. It instead returns the default value. How do I get it to return the visitor’s IP? My Potential clients us the form to contact me but spammers do too.
<input type=hidden name="env_report" value="REMOTE_HOST,REMOTE_ADDR">
What exactly do you expect this to do?
If you want the IP address then look at the client address in the HTTP request the form generates. If the form is dynamically creating an email on the client (i.e. not sending the form data back in an HTTP request) which you want to populate with some values then you’d need to set the values from the code which generates the HTML (javascript doesn’t know about IP addresses) e.g. with PHP….
Only it’s trivial for someone to amend the contents of the email unless you also include some tamper detection….
…and validate on receipt.