當前位置:首頁 » 編程語言 » phppost提交

phppost提交

發布時間: 2022-01-11 09:00:28

『壹』 如何用php向伺服器發送post請求

用PHP向伺服器發送HTTP的POST請求,代碼如下:

<?php
/**
*發送post請求
*@paramstring$url請求地址
*@paramarray$post_datapost鍵值對數據
*@returnstring
*/
functionsend_post($url,$post_data){
$postdata=http_build_query($post_data);
$options=array(
'http'=>array(
'method'=>'POST',
'header'=>'Content-type:application/x-www-form-urlencoded',
'content'=>$postdata,
'timeout'=>15*60//超時時間(單位:s)
)
);
$context=stream_context_create($options);
$result=file_get_contents($url,false,$context);
return$result;
}

使用的時候直接調用上面定義的send_post方法:

$post_data=array(
'username'=>'username',
'password'=>'password'
);
send_post('網址',$post_data);

『貳』 php表單怎樣提交到當前頁面,並用$_POST獲取其值

按照這樣輸入:

<?php

$username=$_POST['username'];

?>

<form action="" ><input type="text" name="username"><input type="submit" name="submit" value="提交"></form>

『叄』 php中POST表單提交的ID如何獲取

通過前台頁面POST回來的表單元素,
在PHP中,使用$_POST[無素名稱]來獲取,
如果沒有指定表單的method的話,瀏覽器會自動使用GET方式,這時則應該使用$_GET[元素名稱]進行獲取
如<form action='' method='post'>
<input type='text' name='id'>
<input type='submit' value='提交'>
</form>
該表單進行提交時
後台PHP使用$_POST['id']進行獲取id的值

『肆』 PHP里模擬Post提交是什麼意思

php
表單提交常見的就是post和get
模擬提交就是通過其他技術達到post或get的效果
php
常見的模擬就是curl方式了
作用比如說刷票
每次提交它可以模擬ip
逃過ip限制
圖片上傳
可以post提交
不用模擬

『伍』 php大神來,post提交文本或者提交文件

前端 index.php

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>無標題文檔</title>
</head>
<body>
<formmethod="post"enctype="multipart/form-data"action="./manage.php"name="">
<inputtype="file"name="uploadfile"id="uploadfile">
<inputtype="submit"name="upload"id="upload"value="上傳">
<form>
</body>
</html>

後端manage.php與index.php同一層

<?php
if(!empty($_FILES["uploadfile"]['tmp_name'])){
$up_name=$_FILES["uploadfile"];
$up_size=$up_name["size"];
$up_type=$up_name["type"];
$up_path=$up_name['tmp_name'];
$up_fname=$up_name['name'];
$exten=pathinfo($up_fname,PATHINFO_EXTENSION);
$objname=date('YmdHis',time());
$save=$objname.'.'.$exten;
$max_size='314572800';//300M1024*1024*300
$up_limit=array("application/msword","text/html","application/pdf","application/vnd.ms-powerpoint","text/plain","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
if(in_array($up_type,$up_limit)&&$up_size<=$max_size&&$up_size>=0){
if(move_uploaded_file($up_path,$save)){
$msg='上傳成功';

}
else{
$msg='上傳失敗';
}
}
else{
$msg='上傳類型或大小不符合';
}
}
else{
$msg='無上傳文件';
}
echo$msg;
?>

『陸』 php post提交

新建一個YZ.php文件(這個文件是你上面form表單action中的)
<?php
$username=$_POST['username_s'];
$password=$_POST['password_s'];
上面就是你想得到的賬號和密碼
?>

『柒』 php post 提交數據

先把JS的提交函數寫好,引入到test.php文件中(別說你不會……)。把函數綁到按鈕的onclick事件上,或者你用setInterval反復執行提交函數。

『捌』 用PHP怎麼發送HTTP POST 請求。怎麼獲得返回結果。

傳遞? 用 form標簽啊 <form action="" method="post"></form>

獲取結果用超全局變數 $_post[]

『玖』 用php做個post提交

看來樓主的截圖,寫的純粹的對curl的運用,個人寫個簡化版的!!
$curl是介面頁面。。。作用是取數據然後傳遞給本頁面!!這個頁面不是來源頁面,只是一個介面文件而已!!如果你連這個頁面都不想要,那就只能在本頁面自己填寫獲取數據的代碼了!!也就不用使用到post數據了!!
$post_val是post提交所需的數據,如果為空,那就是get獲取數據,也就是說$curl要自帶參數,這個要看你介面頁面的程序所定了!!

例子:
1.php
$b = $_GET['k'];
//這邊獲取的就是2.php拋出來的數據。。。
$get_value = curl_file_get_contents(『2.php』,"ct=28&lm=0&word=".$b."&co=23");
var_mp($get_value);//這邊就是你想要的代碼。。隨便你怎麼處理了!!
//這個是curl的精簡版。。。不用那麼多代碼
function curl_file_get_contents($curl,$post_val="")
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curl);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
if($post_val)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_val);
}
$r = curl_exec($ch);
curl_close($ch);
return $r;
}

2.php(介面文件,也相當於把方法寫在另一個文件,通過url調用此方法並回傳值給1.php!!多用於2個文件不在同一程序內,引用(include)不了,又懶得自己再寫個方法,從而通過這種方法獲取,比如說淘寶介面)
$get_key = $_POST['word']; //這邊就指明了只用能post方式獲取數據
..................(這邊就是通過獲取的$get_key來獲取數據,並賦值與$value)......
return $value; //這邊把數據拋給1.php(誰調用介面的就拋給誰)

這樣寫的好處是,假如獲取$value的代碼很長,這樣寫可以減少代碼量!!不在同一個伺服器或者框架下面的程序也可以調用。。。。(同一個框架下的代碼可以用include引入進來!!)
先寫到著吧!!!還有不懂的可以自己網路下或者追問。。我看到了會繼續回答的!!

熱點內容
單片機android 發布:2024-09-20 09:07:24 瀏覽:760
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:660
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:307
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:284
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:813
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:158
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:90
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:503
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:655
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:479