There isn't really a way you can be 100% certain the form data wasn't faked. Referer, cookie and POST data can very easily be sent in a manipulated form. For example, I could forge headers along these lines and send it to your server, and it would be none the wiser:
CODE
POST /script.php HTTP/1.1
Accept: */*
Connection: close
Host: your-host.com
Referer: http://your-host.com/page.html
Cookie: fake-cookie=fake-cookie-data;
xxx-type: application/x-www-form-urlencoded
Content-Length: 3
abc
(Note that
xxx =
Content - IPB is filtering it out).
A session ID can also be easily captured prior to submitting the data (it will most likely be sent either via a cookie, or attached to links), and then be posted along with it. Simply put, and just to re-iterate, there is no 100% certain way you can be sure form data is coming from a page on your server.
Reply