How do you ensure early enough in the PHP request pipeline the verb is POST and deny others?
Asked
Active
Viewed 5,026 times
8
-
1The earliest place to configure this would be in your webserver (presumably apache). It's incredibly trivial in apache, I think. – Noon Silk Apr 27 '10 at 06:59
-
1I wish @silky you make it an answer, not comment – Your Common Sense Apr 27 '10 at 07:23
-
@Col. I didn't make it an answer because I don't know exactly how to configure it in apache; if you figure it out feel free to post it as your own :) – Noon Silk Apr 27 '10 at 21:41
1 Answers
16
This should work:
if ($_SERVER['REQUEST_METHOD'] != 'POST') die();

nickf
- 537,072
- 198
- 649
- 721
-
can't imagine post requests with empty $_POST? ;) a multipart with only file or text/XML for example – Your Common Sense Apr 27 '10 at 07:20
-
@Col. Shrapnel: If you think that's funny you should check PHPoems, there was only really cool that had commands such as unzip, touch, sleep and so on - can't find it though. =( – Alix Axel Apr 27 '10 at 07:22