Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
04-19-2013, 07:35 PM #1
- Join Date
- Apr 2005
- Thanked 0 Times in 0 Posts
Logging a http post by a PHP script
I need somebody to help me to capture the http post coming to a PHP script.
For example I will host this script at my website : http://mydom.com/http_analyser.php
When I post a data like this http://mydom.com/http_analyser.php?u...this+is+a+test
I want to log this data to a log / txt file.
04-19-2013, 07:40 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
The method you have isn't a post, its a get.
Regardless of the method, you simply retrieve the values from the corresponding $_GET or $_POST superglobal, and then write to a file. You can use file_put_contents with the FILE_APPEND as the third argument to write the line you want. The documentation does not specify, but the examples do indicate that you will need to manually add the \n (just use PHP_EOL for it so you don't have to worry about the OS).
Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');