導航:首頁 > 編程語言 > 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請求相關的資料

熱點內容
rpgxp手機編程工具 瀏覽:331
小米電視4谷歌伺服器地址 瀏覽:593
復雜驅動程序編譯 瀏覽:501
西門子數控車床編程指令 瀏覽:615
華為手機電池有沒有加密 瀏覽:221
域名查詢被牆源碼 瀏覽:678
電腦文件夾壓縮包格式 瀏覽:67
安卓堆糖怎麼保存 瀏覽:358
multisim中單片機 瀏覽:603
加密電梯卡怎麼復制到蘋果手機上 瀏覽:304
php獲取數據類型 瀏覽:915
新概念c51單片機 瀏覽:326
刪除文件的命令行 瀏覽:981
java編程軟體eclipse 瀏覽:198
番茄app怎麼完成簽約流程 瀏覽:725
ibm伺服器如何進u盤啟動 瀏覽:185
網路驅動重啟命令 瀏覽:446
入職聯想程序員 瀏覽:155
linux拷貝目錄下所有文件 瀏覽:46
androidwebview測試 瀏覽:234