Trying to get the users IP address added to the forms they send. I currently use Matts FormMail - I assume I'm not able to do it with that ? If not, what is the best form of code to achieve that please ? and the safest from spammers please ? Any help appreciated. Kezi.
Hi There, Simply add this To The PHP, and this to the email echo: I'm not familiar with Matts Formmail, so if my solution is tricky, send me through private message the URL, and I will see if I can direct you how to slot it in. James.
Hi James, Apologies, have had problems logging in, but many thanks for your help on this, I have checked, and double checked thru the form, but can't seem to see where that code would go The URL (thought it would be ok to post here) is http://www.011005.com/form The vers of php on the server is 5, and the page does have the php extn The cosmetic part of it will get more attention, which I can do, but could really do with a little help on making the form to be as safe as possible from the spammers, (w/o captchas), and for the users IP address to be part of the received form. Open to any comments at all, to make the form better in any way. Any help very much appreciated. Kezi.
Add this inside the form tag: <input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>" /> This should do the trick, though you could just get the IP address on the next page... so sending it though the form doesn't make alot of sense.
Many thanks Cri2T, that works perfectly - much appreciated, although I didn't quite understand the last line - sorry ;-( How would I get their IP address, if not putting the code above into the form please ?
You would do something like this on the form-submit page: $ip = $_SERVER['REMOTE_ADDR']; //Put their IP in a variable named ip. PHP: Put that somewhere close to the top of the page (to make sure it gets their IP before you actually need to call the variable) Then wherever you want to display the IP or, whatever you want to do with it, you would simply use that variable. Lets say you want to display it on the page: <?php echo($ip); ?> PHP: If you don't know at-least basic PHP, forget about this post and go ahead and work with the sending through the form method above.
Aah, I think I see what you mean, no, the purpose is not to view the ip address on the page, it's just for me to receive it contained in their emails from the form. Have I understood properly ?
Not exactly, which is fine. The form will work just fine; (once something is in a variable in PHP, you can do pretty much anything with it) If you want, you could PM me the mailing part and I could edit it to include the persons IP address and a timestamp (if you don't already have one)
Many thanks Cri2T, the timestamp isn't needed, but I do get a lot of spam to that form, on the URL posted above - is it not as secure as possible from spammers ? Kezi.