Today I learned the curl Extension function. I wrote an httpPost function, which is effective. I want to use it for online updates or download remote resources online.
[Php]
Echo httpPost ("http://bbs.125.la/member.php? Mod = logging & action = login & loginsubmit = yes & infloat = yes & lssubmit = yes & inajax = 1 ",
Array (
"Handlekey" => "ls ",
"Password" => "123456 ",
"Quickforward" => "yes ",
"Username" => "admin"
));
Function httpPost ($ url, $ sendData)
{
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
// We are posting data!
Curl_setopt ($ ch, CURLOPT_POST, 1 );
// Add the post variable
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ sendData );
$ Output = curl_exec ($ ch );
Curl_close ($ ch );
Return $ output;
}
Echo httpPost ("http://bbs.125.la/member.php? Mod = logging & action = login & loginsubmit = yes & infloat = yes & lssubmit = yes & inajax = 1 ",
Array (
"Handlekey" => "ls ",
"Password" => "123456 ",
"Quickforward" => "yes ",
"Username" => "admin"
));
Function httpPost ($ url, $ sendData)
{
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
// We are posting data!
Curl_setopt ($ ch, CURLOPT_POST, 1 );
// Add the post variable
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ sendData );
$ Output = curl_exec ($ ch );
Curl_close ($ ch );
Return $ output;
}
The following code combines standard mysql Data Query and array
[Php]
$ Conn = mysql_connect ('localhost', 'root', '123 ');
Mysql_select_db ('kefei ');
Mysql_query ("set names utf8 ");
$ Result = mysql_query ("select * from liuyan ");
$ Arr = array ();
While ($ row = mysql_fetch_assoc ($ result )){
$ Arr [] = $ row
}
Var_dump ($ arr );