php表單本頁提交數(shù)據(jù),php表單提交有哪幾種方式

php form表單怎么把數(shù)據(jù)提交到本頁而不跳轉(zhuǎn)?

PHP把表單提交到本頁,這個(gè)的話,我們是通過form action="提交的文件名"來實(shí)現(xiàn)的,還有一個(gè)傳值的方式,post或者是get可以通過METHOD來實(shí)現(xiàn)的,這里我寫一段代碼:

我們提供的服務(wù)有:成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、雙河ssl等。為1000多家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的雙河網(wǎng)站制作公司

html

head/head

body

form action='文件名' method="post"

姓名input type='text' value=""

密碼input type='text' value=""

emailinput type='text' value=""

/form

/body

/html

php表單怎樣提交到當(dāng)前頁面,并用$_POST獲取其值?

?php

/**?filename?:?index.php?*/

header('content-type:text/html;charset=utf-8');

if?(isset($_POST['submit']))?{

print_r($_POST);??//?打印?POST?中的所有數(shù)據(jù)

die;

}

?

form?action?method='post'??//?不要寫action的值或?qū)懏?dāng)前文件名(index.php)?就會(huì)提交到當(dāng)前頁面

...

input?type='submit'?name='submit'?/

/form

如何用php頁面提交表單到數(shù)據(jù)庫

1:首先要使用PHP的超全局變量 $_GET 和 $_POST 用于收集表單數(shù)據(jù)(form-data) 2:然后使用INSERT INTO 語句用于向數(shù)據(jù)庫表中插入新記錄。 具體示例: (1)首先創(chuàng)建了一個(gè)名為 "Persons" 的表,有三個(gè)列:"Firstname", "Lastname" 以及 "Age"。

php表單提交到本頁是什么意思?

就是form表單的action值為空或者寫本頁面的地址,那么表單里面的內(nèi)容數(shù)據(jù)就會(huì)默認(rèn)提交到這個(gè)action值的頁面。

PHP怎么獲取表單提交的數(shù)據(jù)啊?

一、用file_get_contents以get方式獲取內(nèi)容,需要輸入內(nèi)容為:

1、?php

2、$url='';

3、$html = file_get_contents($url);

4、echo $html;

5、?

二、用file_get_contents函數(shù),以post方式獲取url,需要輸入內(nèi)容為

1、?php

2、$url = '';

3、$data = array ('foo' = 'bar');

4、$data = http_build_query($data);

5、$opts = array (

6、'http' = array (

7、 ? 'method' = 'POST',

8、? 'header'= "Content-type: application/x-www-form-urlencoded\r\n" .

9、 ? ? ? ? ? ? ? ? ? ? "Content-Length: " . strlen($data) . "\r\n",

10、 ? 'content' = $data

11、)

12、);

13、$ctx = stream_context_create($opts);

14、$html = @file_get_contents($url,'',$ctx);

15、?

三、用fopen打開url,以get方式獲取內(nèi)容,需要輸入內(nèi)容為

1、?php

2、$fp = fopen($url, 'r');

3、$header = stream_get_meta_data($fp);//獲取信息

4、while(!feof($fp)) {

5、$result .= fgets($fp, 1024);

6、}

7、echo "url header: {$header} br":

8、echo "url body: $result";

9、fclose($fp);

10、?

四、用fopen打開url,以post方式獲取內(nèi)容,需要輸入內(nèi)容為

1、?php

2、$data = array ('foo2' = 'bar2','foo3'='bar3');

3、$data = http_build_query($data);

4、$opts = array (

5、'http' = array (

6、'method' = 'POST',

7、'header'= "Content-type: application/x-www-form-urlencoded\r\nCookie:cook1=c3;cook2=c4\r\n" .

8、"Content-Length: " . strlen($data) . "\r\n",

9、'content' = $data

10、)

11、);

12、$context = stream_context_create($opts);

13、$html = fopen(';id2=i4','rb' ,false, $context);

14、$w=fread($html,1024);

15、echo $w;

16、?

五、用fsockopen函數(shù)打開url,以get方式獲取完整的數(shù)據(jù),包括header和body,需要輸入內(nèi)容為

1、?php

2、function get_url ($url,$cookie=false)

3、{

4、$url = parse_url($url);

5、$query = $url[path]."?".$url[query];

6、echo "Query:".$query;

7、$fp = fsockopen( $url[host], $url[port]?$url[port]:80 , $errno, $errstr, 30);

8、if (!$fp) {

9、return false;

10、} else {

11、$request = "GET $query HTTP/1.1\r\n";

12、$request .= "Host: $url[host]\r\n";

13、$request .= "Connection: Close\r\n";

14、if($cookie) $request.="Cookie:?? $cookie\n";

15、$request.="\r\n";

16、fwrite($fp,$request);

17、while(!@feof($fp)) {

18、$result .= @fgets($fp, 1024);

19、}

20、fclose($fp);

21、return $result;

22、}

23、}

24、//獲取url的html部分,去掉header

25、function GetUrlHTML($url,$cookie=false)

26、{

27、$rowdata = get_url($url,$cookie);

28、if($rowdata)

29、{

30、$body= stristr($rowdata,"\r\n\r\n");

31、$body=substr($body,4,strlen($body));

32、return $body;

33、}

34、 ? return false;

35、}

36、?

參考資料:

php-file_get_contents

分享文章:php表單本頁提交數(shù)據(jù),php表單提交有哪幾種方式
當(dāng)前網(wǎng)址:http://m.kartarina.com/article16/hddggg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)網(wǎng)站制作網(wǎng)頁設(shè)計(jì)公司靜態(tài)網(wǎng)站用戶體驗(yàn)企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)
主站蜘蛛池模板: a级毛片无码免费真人| 日韩AV高清无码| 人妻丰满AV无码久久不卡| 亚洲AV无码精品色午夜果冻不卡| 亚洲不卡中文字幕无码| 精品无码日韩一区二区三区不卡| 亚洲AⅤ无码一区二区三区在线| 小SAO货水好多真紧H无码视频 | 久久无码无码久久综合综合| 精品久久久久久无码中文野结衣| 国产无遮挡无码视频免费软件| 在线观看无码的免费网站| 国产成A人亚洲精V品无码| 少妇无码太爽了不卡视频在线看| 亚洲av无码成人黄网站在线观看| 无码人妻av一区二区三区蜜臀| 无码成人精品区在线观看| 国产成人精品无码一区二区| 亚洲午夜无码片在线观看影院猛| 午夜爽喷水无码成人18禁三级| 日日摸日日踫夜夜爽无码| 国产亚洲精久久久久久无码| YW尤物AV无码国产在线观看| 国模无码视频一区| 无码粉嫩小泬无套在线观看| 精品无码一区二区三区亚洲桃色| 无码人妻精品中文字幕| 亚洲AV永久无码精品水牛影视 | 久久久久成人精品无码中文字幕 | 一本色道久久HEZYO无码| 亚洲äv永久无码精品天堂久久 | 亚洲的天堂av无码| 久久精品中文字幕无码绿巨人| 色AV永久无码影院AV| 少妇人妻无码精品视频| 亚洲av无码成人黄网站在线观看| 亚洲V无码一区二区三区四区观看 亚洲爆乳精品无码一区二区三区 亚洲爆乳无码一区二区三区 | 亚洲天堂2017无码中文| 亚洲国产精品无码中文lv| 亚洲av无码偷拍在线观看| 人妻丰满熟妇AV无码区|