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

熱點內容
手機碎屏解壓工具 瀏覽:243
jsonrpcphp使用 瀏覽:564
網上求職系統源碼 瀏覽:699
pdf數字不顯示 瀏覽:890
convertwordtopdf 瀏覽:253
程序編譯基本單位 瀏覽:23
python分析圖片角度 瀏覽:64
阿里雲伺服器能復制數據嗎 瀏覽:562
python拼音轉換文字 瀏覽:563
動畫遺傳演算法 瀏覽:63
php如何解析xml文件 瀏覽:702
如何改變appstore的語言 瀏覽:462
javahtmlxml 瀏覽:34
單片機啟動文件 瀏覽:811
橙app如何開啟聊天 瀏覽:899
訪問伺服器公網地址 瀏覽:666
pdf列印底色去掉 瀏覽:465
java快遞介面 瀏覽:399
哪個app可以教新爸爸 瀏覽:212
如何查看伺服器系統版本信息 瀏覽:526