HOME 개발팁 PHP에서 CURL을 사용하는 HTTP Post

프로그램 작업하다 좋은 팁, 정보, 테스트를 기록하는 곳입니다.


PHP | PHP에서 CURL을 사용하는 HTTP Post

페이지 정보

작성자 관리자 작성일18-01-12 16:30 조회1,139회 댓글0건

본문

//extract data from the post

    extract($_POST);

 

    //set POST variables

    $url = 'http://www.yourdomain.com/data-post.php';

    $fields = array(

                        'first_name' => urlencode($first_name),

                        'last_name' => urlencode($last_name),

                        'email' => urlencode($email),

                        'phone' => urlencode($phone)

                    );

 

    //url-ify the data for the POST

    foreach($fields as $key => $value) {

        $fields_string .= $key.'='.$value.'&';

    }

    rtrim($fields_string, '&');

 

    //open connection

    $ch = curl_init();

 

    //set the url, number of POST vars, POST data

    curl_setopt($ch,CURLOPT_URL, $url);

    curl_setopt($ch,CURLOPT_POST, count($fields)); //CURLOPT_POST if set true, then you can POST the values.

    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); //CURLOPT_POSTFIELDS will have all the values to be post on the $url.

 

    //execute post

    $result = curl_exec($ch);

 

    //close connection

    curl_close($ch);

[주소복사] https://www.goodsweb.kr/?u=D41KKA5b
SNS 알리기
핀터레스트
텔레그램로
블로그로
카카오스토리
카톡 공유

관련 블로그
로딩중


5명  IP : 18.224.♡.215
001 194.♡.173.99 로그인
(/bbs/login.php?wr_id=30&sca=%EC%8B%A0%EA%B7%9C&page=1&url=http://www.goodsweb.kr/bbs/board.php%3Fbo_table=postulat%26amp;wr_id=30%26amp;sca=%25EC%258B%25A0%25EA%25B7%259C%26amp;page=1)
002 195.♡.219.133 굿스웹 - 홈페이지 유지보수 관리
(/)
003 121.♡.231.81 로그인
(/bbs/login.php?wr_id=31&&url=https%3A%2F%2Fwww.goodsweb.kr%2Fbbs%2Fboard.php%3Fbo_table%3Dpmall%26amp%3Bwr_id%3D31)
004 27.♡.238.68 SKT NUGU 누구 NU110WA AS 고객센터 - 생활정보
(/bbs/board.php?bo_table=info&wr_id=18)
005 211.♡.68.2 SKT NUGU 누구 NU110WA AS 고객센터 - 생활정보
(/bbs/board.php?bo_table=info&wr_id=18)

접속자
  • 오늘 : 150
  • 어제 : 337
  • 최대 : 874
  • 전체 : 406,042

검색로봇(Robots) 최근 방문시간
  • GOOGLE : 2시간 전
  • NAVER : 3시간 전
  • DAUM : 4일 전
  • BING : 6일 전

ETH : 0x8abf3B748ab78828AE07685e4fd53d1a606f18D3



페이스북 네이버 블로그 굿스웹 쇼핑몰 네이버 카페 굿스웹 트위터 굿스웹 티스토리 Google Play