I'm not 100% sure exactly what you're asking, but here's what I think:
When a form is submitted, the request comes from the user not the server. If you only allow requests from localhost then no one can use the form unless they happen to be on the local machine your server is running on.
I think what you want to do is
1. Only allow POST requests to results.php
2. Prevent POST requests that did not originate from the intended form from being processed.
The first one is simple,
PHP Code:
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
//process request
}
For the second one, try using a nonce. When implemented correctly a user (or spam bot) must actually visit the page the form is on in order to have their request processed. Note that a nonce does not entirely prevent automated requests, but they can make them a little more difficult to pull off.
Last edited by NullPointer; 04-05-2011 at 05:26 AM..
|