<?php

function form_post_check()
{
  $referring_url = $_SERVER['HTTP_REFERER'];    // get the referring URL
  $host = $_SERVER['HTTP_HOST'];    // get the header from the current request (example: www.yoursite.com)
  $valid_url = 'http://'.$host.'/';    // finish defining a valid referring URL
  $valid_len = strlen( $valid_url );    // get the length of the valid url
  
  // if the valid url isn't the first part of the referring url
  if ( substr( $referring_url, 0, $valid_len ) != $valid_url )
    {
      die( 'You submitted this form from an invalid URL.' );    // stop everything and display a message
    }
}

?>