奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

php語言

使用php自動提交表單的方法

時間:2025-05-19 22:04:36 php語言 我要投稿
  • 相關推薦

使用php自動提交表單的方法

  介紹了php自動提交表單的方法,結合實例形式分析了php基于fsockopen與curl兩種實現技巧,需要的朋友可以參考下。

  fsockopen和curl都可以做php自動提交表單

  1. fsockopen方法:

  php代碼:

  46

  47

  48

  49

  <?php

  /*-----------------------------------------------------------

  *功能:使用PHP socke 向指定頁面提交數據

  *作者:果凍  說明:post($url, $data)

  *

  *    $url   = 'http://www.xxx.com:8080/login.php';

  *    $data[user] = 'hong';

  *    $data[pass] = 'xowldo';

  *    echo post($url, $data);

  *-----------------------------------------------------------*/

  function post($url, $data) {

  $url = parse_url($url);

  if (!$url) return "couldn't parse url";

  if (!isset($url['port'])) { $url['port'] = ""; }

  if (!isset($url['query'])) { $url['query'] = ""; }

  $encoded = "";

  while (list($k,$v) = each($data)) {

  $encoded .= ($encoded ? "&" : "");

  $encoded .= rawurlencode($k)."=".rawurlencode($v);

  }

  $fp = fsockopen($url['host'], $url['port'] ? $url['port'] : 80);

  if (!$fp) return "Failed to open socket to $url[host]";

  fputs($fp, sprintf("POST %s%s%s HTTP/1.0n", $url['path'], $url['query'] ? "?" : "", $url['query']));

  fputs($fp, "Host: $url[host]n");

  fputs($fp, "Content-type: application/x-www-form-urlencodedn");

  fputs($fp, "Content-length: " . strlen($encoded) . "n");

  fputs($fp, "Connection: closenn");

  fputs($fp, "$encodedn");

  $line = fgets($fp,1024);

  if (!eregi("^HTTP/1.. 200", $line)) return;

  $results = ""; $inheader = 1;

  while(!feof($fp)) {

  $line = fgets($fp,1024);

  if ($inheader && ($line == "n" || $line == "rn")) {

  $inheader = 0;

  }

  elseif (!$inheader) {

  $results .= $line;

  }

  }

  fclose($fp);

  return $results;

  }

  /*

  $url = 'http://video.xxx.com:80/game_vm.php';

  $data['gid'] = '1';

  echo post($url, $data);

  */

  ?>

  2. Curl方法:

  php代碼:

  ?

  1

  2

  3

  4

  5

  6

  7

  8

  9

  10

  11

  12

  13

  14

  <?php

  $url = 'http://localhost/curl/result.php';

  $params = "param=123?m2=333"; //What will be posted

  $user_agent = "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)";

  $ch = curl_init();

  curl_setopt($ch, CURLOPT_POST,1);

  curl_setopt($ch, CURLOPT_POSTFIELDS,$params);

  curl_setopt($ch, CURLOPT_URL,$url);

  curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);

  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

  $result=curl_exec ($ch); //execut

  curl_close ($ch);

  echo "Results: <br>".$result;

  ?>

  result.php (just for test)

  ?

  1

  2

  3

  <?php

  print_r($_POST);

  ?>

【使用php自動提交表單的方法】相關文章:

PHP提交from表單的方法07-05

php防止表單重復提交的方法10-16

php提交form表單處理方法07-12

用PHP提交from表單的處理方法09-06

如何讓php提交form表單11-06

php表單提交與$-POST實例分析11-15

解決表單重復提交問題的PHP代碼11-02

PHP 表單驗證方法11-01

php通過記錄IP來防止表單重復提交方法分析10-17

主站蜘蛛池模板: 白水县| 枣阳市| 夏邑县| 晋江市| 绩溪县| 平陆县| 德格县| 永定县| 伊通| 原阳县| 江城| 祁门县| 卫辉市| 公安县| 区。| 新津县| 辽阳市| 廉江市| 富蕴县| 营口市| 大安市| 广东省| 天水市| 余姚市| 睢宁县| 金溪县| 浑源县| 崇义县| 巫溪县| 延川县| 陇川县| 哈密市| 玉田县| 葫芦岛市| 巴东县| 建水县| 平罗县| 南充市| 香格里拉县| 麻栗坡县| 正阳县|