I've been trying to get the visitor IP address (and host if possible) put into a hidden field to submit with a contact form.
The site is hosted on godaddy so the submission form is gdform.php. I haven't had much luck tinkering with their php file, so I'd rather place this in the html form I guess. (But willing to try anything.
The field for IP will be named/id'd as "ip", the field for host is "host"
You should not have this information. Spamming is the only reason anyone wants it.
The IP address is usually useless anyway. Most ISPs, hosts, and routers now generate one-time IP addresses, to prevent spamming. Each time someone logs in, they get a new one.
I am not a spammer, don't sell anything via the internet/email (except a handful of ebay items/year) and I use IP addys often.
My contact form is for people to contact my our small underfunded $2,000/ annual budget? and ask for assistance. Before we spend significant time resources researching their issue, we'd like to know if they are from the East Coast like they say, or really from Nigeria.
Since every email contains an IP address, getting one from the contact form is not unreasonable.
You should not have this information. Spamming is the only reason anyone wants it.
The IP address is usually useless anyway. Most ISPs, hosts, and routers now generate one-time IP addresses, to prevent spamming. Each time someone logs in, they get a new one.
most godaddy hosting includes php
the php $_server[] array used in the godaddy form already includes this information
its a matter of changing your html form to a php form (by changing the file extension)
and coding something like
Very few IP address change except those on dialup.
the ISP has to retain the information for billing and liability protection,
the more often they alter the ip,
the more data they have to retain
mine usually alters every 6 months
the ip data and all page access data is retained in the server logs, this is no ideal world, everything is logged
:attachment: server log image
Yes, my godaddy hosting includes php and the form is being submitted using php - a standard form created by gd.
I have created html documents for almost 9 years, but just have attempted using php. (I did create a php submittal file for a form created on a different server.)
The code you gave me makes perfect sense, but I can't get it to work.
I've tried taking my whole html and making it a text php file - I get all kinds of parsing errors, I'm sure my html is not coded in an up-to-date fashion. I use KompoZer to create.
Almostbob - Thanks for the reply. Yes, my godaddy hosting includes php and the form is being submitted using php - a standard form created by gd.
I have created html documents for almost 9 years, but just have attempted using php. (I did create a php submittal file for a form created on a different server - didn't inlcude IPs.)
The code you gave me makes perfect sense, but I can't get it to work.
Here is what I've tried:
- I've tried taking my whole html and making it a text php file - I get all kinds of parsing errors, I'm sure my html is not coded in an up-to-date fashion. I use KompoZer to create my html.
- I've tried creating a php file "contactform.php" with just the code you gave me, then including this within my html form:
I hope this is enough that someone can point out what obvious mistake(s) I'm making.(I can't get php to include anything, even a text footer, in my website. I read this thread http://www.daniweb.com/forums/thread200844.html an tried to do exactly)
For php includes, or php embedded in the original html form, did you rename the "outer"form from "formname".html to "formname".php so the server will know to parse it for php
else the html parser will just find 'wrong' tags instead of the php parser parsing the php then sending the generated stuff on as html
Not sure the answer to this question. My page is html and called contact.html. There is one "form" in the page. The action is
<form action="gdform.php" method="post"><input
name="redirect" value="thankyou.html" type="hidden"><input
name="subject" value="Website Contact" type="hidden">
Standard form fields (within a table if that makes a difference). Then
<input value="Submit" type="submit"> </form>
Everything works and send to me except the IP/Host issue. The gdform.php contents are created by gd, and are listed in my first post. (I can edit it).
Tried the two different php options you gave me and did not work, but should I be creating a second form?
Thank you so much for your help!For php includes, or php embedded in the original html form, did you rename the "outer"form from "formname".html to "formname".php so the server will know to parse it for php
else the html parser will just find 'wrong' tags instead of the php parser parsing the php then sending the generated stuff on as html
Here is the first part and last part of the table. There are a few other fields, but no different 'types'. There is one more 'select' list. They are just unformated text entry fields, identical to the "Name" field.
.
the php is not being parsed in the form
is the form extension .php so that php in the form will be recognized
or is it still labelled .htm/.html
I have a mental blank on any other reason
Yes, you are right I was confused about the file extension.
Step 1 in solving my problem was to File Save As then change the extension to .php
I was confused about that, and originally tried renaming it, but also mangled some other things too.
Step 2
Here is the exact language that finally worked for me:
I believe I had to use Caps to make it work.
REMOTE_HOST returned the same thing as REMOTE_ADDR for me, so I found the gethostbyaddr from some website today.
For other non-experts like me working on this problem, I found it useful to have the type="text" for my working models. Then once it is uploaded, you can 'see' right away whether it is actually pulling the IP.
Once I got it to work, I swtiched the type to "hidden".
Ditto
the next changes, will be easy
have you seen
<?php //stats.php
// Get the user stats.
$getdate = date( 'd-m-Y, H:i:s' );// Get the date.
$user_ip = $_SERVER['REMOTE_ADDR'];// Get the users IP.
$user_browser = $_SERVER['HTTP_USER_AGENT'];// Get the browser.
$referer = $_SERVER["HTTP_REFERER"];// Get the refering page.
// Look for the text file and open it for writting.
$file = "./logfiles/logfile.csv";// define the text file.
$fp = fopen($file, "a+");//open the text file for writing.
// Write the user stats into the text file.
fputs ($fp, "$user_ip,$getdate, $referer\n");
fclose($fp);// Close the text file.
?>
If you <?php include('./stats.php'); ?> in your files it creates a comma separated list of who went where and when.
just an :icon_evil: thought
You can log your site, even if you dont have access to the server logs http://www.bbclone.de is "a web counter on steroids" the earlier screen dump is of a bbclone script page
Hadn;t seen that one. I've downloaded logs from my old host before, and godaddy seems to allow me to download as well.
Then I use the freebie webhostexpert lite to produce some stats etc.
But I have also been using an outside source 'statcounter' I think which produces nice free paths (but limited to 500 entries) of who visited which page in which order.
I'll look into your suggestion though to see what it might produce.
strange - the IP I get everytime I send the form is the same.
And looking at the site stats, the IP of many people who browse is the same - i know who they are.
I know it is possible to browse using anonymously, but the vast majority don't, or at least the vast majority of folks who visit my sites don't, so having the IP is helpful to me.
Every ISP I have ever used since 1998 has created dummy IP addresses. I haven't had dial-up since 1993.
The IP address the ISP gets is real. But anything it puts out on the Internet has a one-time throwaway IP address.