Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    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.

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 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).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts