Forum Moderators: coopster
1) Use the servers superglobal http_referer and check that string for your url. This could be hoxed but it's not something everyone knows how to do BUT if a referer doesn't exist this will also fail.
Example
<?$referer = $_SERVER['HTTP_REFERER'];
if (strstr($referer, 'www.mywebsite.com'))
{
// You may proceed!
}?>
strstr checks for the first string inside another string, if it exists it will return true;
2) Create a random string and store it as a session variable, this is a better approach because the string can only be set on your website and can not be stored by any other means.
<?session_start();
$_SESSION['key'] = rand(1, 100000000);
?>
I wouldn't just use numbers for the string, but that's something you could expand.
Then for the process page.
<?session_start();
if (isset($_SESSION['key']))
{
// You may proceed!
}
?>
I hope i have helped a little.
Del
Unless there are other ideas (perhaps something built into PHP) I suppose I'll just have to ensure that I have some crazy-good error checking to prevent database fiddling.
The ones i have wrote or worked with also use sessions so a brute force attack can not be made to these forms. That would be the better solutions to come to think of it.
I use a free script called "freecap", curtosy of puremango. It's one of the best systems out and the guy who developed it has a real good reputation and has helped other companies improve the protection of there own image verification scripts.
Good luck with your Journey!
Del
Also, your forms are susceptible to SQL injection if you don't escape the content before sending it to the SQL database.
PHP Security [webmasterworld.com]
PHP Peer Code Review [webmasterworld.com]
Combatting Webform hijack [webmasterworld.com]
SQL Injection Vulnerability [webmasterworld.com]
all good Library threads