PHP Analog Post submission data method, PHP analog post submission _php tutorial

Source: Internet
Author: User
Tags php programming bbpress

PHP Analog Post submission data method, PHP analog post submission


The example in this article describes how PHP simulates post submission data. Share to everyone for your reference. Specific as follows:

PHP analog post submission data, a lot of useful, can be used for site collection, landing and so on

Here is an example of a forum login in my project, which illustrates:
Copy CodeThe code is as follows: function A_bbslogin ($user _login, $password, $host, $port = "80") {
Post data that needs to be submitted
$ARGV = Array (
' Cookie ' = = Array (' User_login ' + $user _login, ' password ' = ' $password, ' _wp_http_referer ' = '/bbpress/', ' Re ' = ', ' Remember ' =>true)
);
foreach ($argv [' Cookie '] as $key = + $value) {
$params [] = $key. '=' . $value;
}
$params = Implode (' & ', $params);
$header = "post/bbpress/bb-login.php http/1.1\r\n";
$header. = "Host: $host: $port \ r \ n";
$header. = "content-type:application/x-www-form-urlencoded\r\n";
$header. = "Content-length:". Strlen ($params). "\ r \ n";
$header. = "connection:close\r\n\r\n";
$header. = $params;
$fp = Fsockopen ($host, $port);
Fputs ($fp, $header);
while (!feof ($fp)) {
$str = fgets ($FP); Here is your own logic code, here is the main analog cookie, can be used to synchronize login
if (! ( Strpos ($str, "Set-cookie:") = = = = False)) {
$tmparray = Explode ("", $str);
$cookiearray = explode ("=", $tmparray [1]);
$cookiepaths = explode ("=", $tmparray [6]);
$cookiename = UrlDecode ($cookiearray [0]);
$cookievalue = UrlDecode (substr ($cookiearray [1],0,strlen ($cookiearray [1])-1);
$cookietime = time () +3600*24*7;
$cookiepath = UrlDecode (substr ($cookiepaths [1],0,strlen ($cookiepaths [1])-1);
Setcookie ($cookiename, $cookievalue, $cookietime, $cookiepath);
}
}
Fclose ($FP);
}

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/957117.html www.bkjia.com true http://www.bkjia.com/PHPjc/957117.html techarticle PHP Analog Post Submission data method, PHP analog post submitted in this article is an example of the PHP simulation post submission data method. Share to everyone for your reference. The following: PHP analog post submission ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.