- Impact
- 2
I use this code each time a form is submitted to check to make sure external scripts aren't run when a user wants to submit the data
It also has other uses. Basically an extra security precaution
It also has other uses. Basically an extra security precaution
PHP:
<?php
// Set this to your domain name
$referer = "domain.com";
// Explode the HTTP_REFERRER address to split up the string
$ref = explode('/', $_SERVER['HTTP_REFERER']);
// next piece of code checks for the 'www.'
// Some people use http://domain.com and others use http://www.domain.com. This will remove the 'www.' as to let users have their choice
if (strstr($ref['2'], 'www.')) { $ref['2'] = str_replace('www.', '', $ref['2']); }
// check if they match or not
if ($ref['2'] != $referer)
{
echo "You are not allowed to enter information from an external form.";
}
else
{
// Continue with script
}




