導航:首頁 > 編程語言 > php提交post請求

php提交post請求

發布時間:2022-09-24 11:53:49

A. 請教php post 提交限制問題

在php中要模擬post請求數據提交我們會使用到curl函數,下面我來給大家舉幾個curl模擬post請求提交數據例子有需要的朋友可參考參考。 注意:curl函數在php中默認是不被支持的,如果需要使用curl函數我們需在改一改你的php.ini文件的設置

B. 用PHP怎麼發送HTTP POST 請求。怎麼獲得返回結果。

<form action="PHP.php" method="POST">
<input type="text" name="name">
<input type="submit" name="submit">
</form>
直接提交就能將內容以POST方式發送到PHP頁面了。
至於怎麼接收很簡單,用$_POST,這是一個數組。
print_r($_POST);

GET是在地址欄可見的,而POST是不可見的。具有保密性。。
一般機密性的數據用POST傳送。

C. 怎麼用PHP發送POST請求

PHP發送POST請求的三種方式

classRequest{

publicstaticfunctionpost($url,$post_data='',$timeout=5){//curl

$ch=curl_init();

curl_setopt($ch,CURLOPT_URL,$url);

curl_setopt($ch,CURLOPT_POST,1);

if($post_data!=''){

curl_setopt($ch,CURLOPT_POSTFIELDS,$post_data);

}

curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);

curl_setopt($ch,CURLOPT_HEADER,false);

$file_contents=curl_exec($ch);

curl_close($ch);

return$file_contents;

}


publicstaticfunctionpost2($url,$data){//file_get_content$postdata=http_build_query(

$data

);$opts=array('http'=>

array(

'method'=>'POST',

'header'=>'Content-type:application/x-www-form-urlencoded',

'content'=>$postdata

)

);$context=stream_context_create($opts);


$result=file_get_contents($url,false,$context);

return$result;


}


publicstaticfunctionpost3($host,$path,$query,$others=''){//fsocket


$post="POST$pathHTTP/1.1 Host:$host ";

$post.="Content-type:application/x-www-form-";

$post.="urlencoded ${others}";

$post.="User-Agent:Mozilla4.0 Content-length:";

$post.=strlen($query)." Connection:close $query";

$h=fsockopen($host,80);

fwrite($h,$post);

for($a=0,$r='';!$a;){

$b=fread($h,8192);

$r.=$b;

$a=(($b=='')?1:0);

}

fclose($h);

return$r;

}
}

http://www.oschina.net/code/snippet_729516_33065

D. php怎麼發送get/post請求

index.html頁面

<formaction="data.php"method="post">//這是post請求方法
<inputtype="text"name="data"value="要提交給伺服器的內容。"/>
<inputtype="button"value="提交"/>
</form>

<formaction="data.php"method="get">//這是get請求方法
<inputtype="text"name="data"value="要提交給伺服器的內容。"/>
<inputtype="button"value="提交"/>
</form>

data.php頁面

<?php
//列印全局數組
print_r($_POST);
//作用是列印出你提交的數據。
print_r($_GET);
?>

代碼可以直接拿到環境中測試,祝你早日成功。

閱讀全文

與php提交post請求相關的資料

熱點內容
什麼是適合自己的app 瀏覽:451
雲伺服器怎麼補漏洞 瀏覽:176
如何看自己的安卓是什麼等級 瀏覽:633
被丁磊挖走的程序員 瀏覽:19
gsk980ta編程 瀏覽:507
單片機離線 瀏覽:84
解壓助眠敲擊外國長指甲 瀏覽:421
3次元編程 瀏覽:803
夫妻傳送英文命令 瀏覽:316
程序員題代做 瀏覽:950
戴爾伺服器怎麼擴大內存 瀏覽:641
解壓包密碼消失 瀏覽:135
昆侖通態觸摸屏用戶窗加密 瀏覽:564
農信app怎麼看日額 瀏覽:865
iphone備忘錄包含視頻無法加密 瀏覽:283
抖音快手紅包源碼 瀏覽:137
程序員資源分析 瀏覽:586
linux交換分區大小 瀏覽:922
mt怎麼編譯 瀏覽:337
qq郵箱打開pdf 瀏覽:461