| 01/11/2015 Learn a little more about PHP World each day, with www.Planet-Source-Code.com's Code of the Day! Current # of subscribers: 5,990 |
Make 9 cents to $300 per game playing Dollar Candy. The better you get, the more you make. Click for more info.
=================================================================
Would you like access to thousands of lines of source code instantly from your desktop? Then check out the Planet Source Code CD...hundreds of amazing programs at your fingertips with no online wait!
Click Here!
Code of the Day: (What is the code of the day? )
1) Post data using curl
Submissions Since Yesterday:
NONE
1)Post data using curl
Category: Coding Standards
Level: Intermediate
Description: Se here: http://agalaxycode.blogspot.in/2015/01/post-data-using-curl.html Problem: How to post data using curl in php? Solution: You need to use POST method in curl. Example: $str_to_post = "login=mylogin&pass=mypass"; $crl = curl_init('http://localhost/mysite/dologin'); curl_setopt($crl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($crl, CURLOPT_POSTFIELDS,$str_to_post ); curl_setopt($crl, CURLOPT_RETURNTRANSFER, true); $ans = curl_exec($crl); Other example is: $postdata = array( 'login' => 'mylogin', 'pass' => 'mypass', 'logintype' => '1' ); $crl = curl_init(); curl_setopt($crl, CURLOPT_URL, "http://localhost/mysite/dologin"); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($crl, CURLOPT_POST, true); curl_setopt($crl, CURLOPT_POSTFIELDS, $postdata); $ans = curl_exec($crl);
Compatibility: PHP 5.0
Submitted on 1/8/2015 1:26:30 AM and accessed 35 times.
Back to Top
No comments:
Post a Comment