Đề mục chính
| | |
Cấu trúc diễn đàn
| | |
Thống kê
| |
Đề tài: 10611
Bài gửi: 12175
Thành viên: 20,205
Thành viên tích cực: 81 |
Xin cùng nhau chào đón thành viên mới nhất: ddvtien |
Kỷ lục: 624 người đã ghé thăm 17/11/2010 lúc 06:16 AM.
| Số người đang xem
| | | |  | 
01/03/2010, 11:57 PM
| Code chuẩn POST dữ liệu trong PHP | Admintalk's Staff can't stop talking
Bài gởi: 4,003
My Mood: Thanks: 27
Thanked 210 Times in 152 Posts
VP: 0.00 Donate | PHP - Code chuẩn POST dữ liệu
Cách 1 PHP Code: <?php
$server='addnick.com';
$urlsend='http://www.addnick.com/send.php?id=chat';
$whosend='http://addnick.com/chat_dangky.php';
$dulieu="nickyahoo=manman89&nam=12589&phai=0&khuvuc=07&B2="Xóa tất cả"&B2="Ðăng ký nick"";
$fp = fsockopen($server, 80, $errno, $errstr, 30);
if (!$fp){
exit;
} else {
fputs($fp, "POST ".$urlsend." HTTP/1.1n");
fputs($fp, "Host: ".$server."n");
fputs($fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6n");
fputs($fp, "Referer: ".$whosend."n");
fputs($fp, "Content-type: application/x-www-form-urlencodedn");
fputs($fp, "Content-length: ".strlen($dulieu)."n");
fputs($fp, "Connection: closenn");
fputs($fp, $dulieu."n");
while(!feof($fp)) $d .= fgets($fp,4096);
fclose($fp);
echo $d;
}
?> Cách 2 : PHP Code: function manman89senddulieu($link='',$method='GET',$header='',$dulieucansend='')
{
$mangmethod=array("get","post");
if (!in_array(strtolower($method),$mangmethod)){return "ManMan89 Say : ERROR METHOD";}
if (strtolower($method)=="get" && $dulieucansend!="")
{
$dulieucansend=http_build_query($dulieucansend);
}
elseif (strtolower($method)=="post" && $dulieucansend!="")
{
foreach ($dulieucansend as $key => $value)
{
$dulieurac=$dulieurac.$key."=".$value."&";
}
$dulieucansend=substr($dulieurac,0,strlen($dulieurac)-1);
}
if($header!="" && $link!="")
{
$opts = array(
'http'=>array(
'method' => $method,
'header' => $header,
'content' => $dulieucansend
)
);
$context = stream_context_create($opts);
$fp = fopen($link, 'r', false, $context);
$homepage = stream_get_contents($fp);
$meta = stream_get_meta_data($fp);
return array(
'headerz' => $meta,
'dulieuz' => $homepage
);
}
}
$link='http://my.opera.com/vanmankey';
$xaydungdulieucansend = array
(
'username' => 'vanmankey',
'password' => '1234567890',
'remember' => '1'
);
$header="Accept-language: enrn".
"Host: my.opera.comrn".
"Referer: http://my.opera.com/vanmankey\r\n".
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6rn";
$mangdulieu=manman89senddulieu($link,'GET',$header,$xaydungdulieucansend);
/* === Lay cookies all ===
$mangdulieu=implode("\r\n",$mangdulieu['headerz']['wrapper_data']);
preg_match_all('/Set-Cookie: (.*?); /',$mangdulieu,$dulieuok);
$dulieuok=implode("; ",$dulieuok[1]);
$cookie="Cookie: ".$dulieuok;
*/
print_r($mangdulieu);
?>
[/quote] Bài viết cùng chủ đề: |
| |  | |
Ðang đọc: 1 (0 thành viên và 1 khách) | | | | Ðiều Chỉnh | Kiếm Trong Bài | | | | | Xếp Bài | Linear Mode |
Quyền Sử Dụng Ở Diễn Ðàn
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML đang Tắt | | | |