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

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


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

페이지 정보

작성자 관리자 작성일18-01-12 16:30 조회1,140회 댓글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=D415TEuS
SNS 알리기
핀터레스트
텔레그램로
블로그로
카카오스토리
카톡 공유

관련 블로그
로딩중


3명  IP : 18.221.♡.47
001 135.♡.213.219 node-v10.15.0-x64.msi Download - 개발팁
(/bbs/board.php?bo_table=tip&wr_id=107&sca=%EC%9E%90%EB%A3%8C)
002 222.♡.104.209 굿스웹 - 홈페이지 유지보수 관리
(/)
003 216.♡.66.232 차트 포인트 주기 - 옵션열기
(/bbs/board.php?bo_table=mo&wr_id=7&page=1)

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

검색로봇(Robots) 최근 방문시간
  • GOOGLE : 7시간 전
  • NAVER : 8시간 전
  • DAUM : 5일 전
  • BING : 6일 전

ETH : 0x8abf3B748ab78828AE07685e4fd53d1a606f18D3



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