InfoSec Forums InfoSec Forums Programming Send POST Request with PHP

This topic contains 0 replies, has 1 voice, and was last updated by do son do son 2 months, 1 week ago.

  • Author
    Posts
  • #3697
    do son
    do son
    Moderator
    • Topics:202
    • Comments:51
    • Super Member
    • ★★★★

    Using PHP to send POST requests

    / **
    * Send a request post
    * @param String $ url address request
    * @param Array $ post_data post key data
    * @return String
    * /
    function send_post ($ url, $ post_data) {

    $ Postdata = http_build_query ($ post_data);
    $ Options = array (
    'Http' => array (
    'Method' => 'POST',
    'Header' => 'Content-type: application / x-www-form-urlencoded',
    'Content' => $ postdata,
    'Timeout' => 15 * 60 // timeout (unit: s)
    )
    );
    $ Context = stream_context_create ($ options);
    $ Result = file_get_contents ($ url, false, $ context);

    return $ result;
    }
    //Instructions
    $ Post_data = array (
    'Username' => 'ddos',
    'Password' => 'mypassword'
    );
    send_post ( 'http://kali-linux.co', $ post_data);

     

     

    No system is truly secure!

You must be logged in to reply to this topic.