Home > Backend Development > PHP Tutorial > PHP submits data via Post

PHP submits data via Post

WBOY
Release: 2016-07-25 08:43:55
Original
1158 people have browsed it
  1. $postData = array();
  2. $postData['data1'] = "testdata1";
  3. $postData['data2'] = "testdata2";
  4. $postData['data3'] = "testdata3";
  5. $url='http://yourdomain/do.php';
  6. $str="";
  7. foreach ($postData as $k=>$v)
  8. {
  9. $str.= "$k=".urlencode($v)."&";
  10. }
  11. $postData=substr($str,0,-1);
  12. $c = curl_init();
  13. curl_setopt($c, CURLOPT_POST, 1);
  14. curl_setopt($c, CURLOPT_HEADER, 0);
  15. curl_setopt($c, CURLOPT_URL,$url);
  16. curl_setopt($c, CURLOPT_POSTFIELDS, $postData);
  17. $result = curl_exec($c);
复制代码

PHP, Post


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template