Forum
Subscribe


IP in Contact Form

IP address in contact form emails

Use this customisation to set the contact form up so that it automatically collects the IP address of the sender, and includes it in the email you receive.

On the contact.php page, find the contact form code, which begins with:

<form method='POST'>

Just after that are several hidden form fields, the first of which is:

<input type=hidden name=user_form value='email'>

After the last of these hidden fields, copy and paste the following code:

<input type=hidden name=userform[ip_address] value='<?PHP echo $_SERVER['REMOTE_ADDR'] ?>'>

Save the file (and upload it if you edit via FTP rather than CPanel).

Go to your contact page and send yourself a test mail.

WARNING: Make a backup copy of the contact.php file before you begin, just in case you make a mistake.