PHP - Bits & Pieces

PHP programming codes and scripting are discussed in the manner of use and relevance. Examples of PHP syntax and scripting are presented in concise writups for better understanding.

Tuesday, June 3, 2008

Use PHP to track email sender from your web site

How do you know the emails that you received through your web site html form came from a trust worthy source? Often we received machines sent messages and falls victim to spamming on our email account. One way to prevent this and track spamming is to get the sender's IP, page of reference (the url link that refers the sender to to your email page) and user agent (browser).

Example of Use:


On your email form page include the following codes:


$ipi = getenv("REMOTE_ADDR"); // IP address.
$httprefi = getenv ("HTTP_REFERER"); // Url link of Reference Page.
$httpagenti = getenv ("HTTP_USER_AGENT");// Browser info.

//send for processing through your html form. Hide them in hidden fields so that only you get the information on the sender.
<input type="hidden" name="ip">
<input type="hidden" name="httpref">
<input type="hidden" name="httpagent">


When processing the form, you may want to check that all the 3 inputs are not empty before you continue. If they are, it most likely that they are send by a machine.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home