<?php

/**
* Change 'yourdomain.com' to your domain name, no www.
* It's best to put this code in a global file (file that is included on all pages)
* before any other code.
*/

if (count($_POST) > 0)
{
    if ($_SERVER['HTTP_REFERER'])
    {
        $referrer_parts = @parse_url($_SERVER['HTTP_REFERER']);
        $ref_port = intval($referrer_parts['port']);
        $ref_host = $referrer_parts['host'] . (!empty($ref_port) ? ":$ref_port" : '');

        if (strpos($ref_host, 'yourdomain.com') === false)
        {
            die();
        }
    }
}

?>