快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

php直接获取表单数据,php获取表单按钮的值

php 如何获取表单中的一系列值?

php是服务器端脚本,如果上面的表单是你服务器端编写的,可以直接传值 id、class 等给php脚本进行查询就可以了;如果上面的表单是你获取其他站点上,那通常的做法,可以使用正则来提取值再传给php脚本进行查询。

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:主机域名虚拟主机、营销软件、网站建设、梨树网站维护、网站推广。

php怎么获取form表单提交的数据

一般是用post获取提交的数据,如下实例:

form name="form1" method="post"

p用户名:input type="text" name="uname" //p

p密码:input type="password" name="upwd" //p

pinput type="submit" name="btn" value="提交" //p

?php

if ($_POST["btn"]){

echo '用户名:'.$_POST["uname"].'br';//三体教程

echo '密码:'.$_POST["upwd"];

}

?

/form

php怎么从表单接收数据

PHP 可以通过POST、GET方法获取到表单提交的数据

获取到的POST、GET是数组形式的值,需要通过键值来详细获取相应的值

比如: index.php 页面

下面是POST方法

form name="form1" method="post" action="index.php"

input type="text" name="contents" value=""

input type="submit" value="提交"

/form

?php

//获取表单提交的数据

$contents = $_POST['contents'];

echo $contents;

?

也可以是下面是GET方法

form name="form1" method="get" action="index.php"

input type="text" name="contents" value=""

input type="submit" value="提交"

/form

?php

//获取表单提交的数据

$contents = $_GET['contents'];

echo $contents;

?

POST相对于GET方法,更好一些,可以提交大量数据,以及更安全些。

php怎么获取表单中提交的数据?

在获取表单数据中,最常用的自动全局变量是$_GET和$_POST,它们分别获取通过GET方法提交的数据和通过POST方法提交的数据。

比如一个名称为"user"的文本框表单控件,如果用GET方法提交,可以用 $_GET["user"]或者$_GET['user']

获取它提交的值。

php 即时获取表单值

光用php无法实现这个功能,一般来说,需要利用javascript代码:

html

head

meta charset="UTF-8" /

script type="text/javascript"

function checkLength(which)

{

var curr = which.value.length+1;

document.getElementById("chCount").innerHTML = curr.toString();

}

/script

/head

body

form method="post" action=""

input name="text" type="text" onkeypress="checkLength(this)" /

br /

你已输入了 span id="chCount"0/span 个字.

/form

/body

/html

PHP怎么获取表单提交的数据啊?

一、用file_get_contents以get方式获取内容,需要输入内容为:

1、?php

2、$url='';

3、$html = file_get_contents($url);

4、echo $html;

5、?

二、用file_get_contents函数,以post方式获取url,需要输入内容为

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方式获取内容,需要输入内容为

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方式获取内容,需要输入内容为

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函数打开url,以get方式获取完整的数据,包括header和body,需要输入内容为

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直接获取表单数据,php获取表单按钮的值
当前URL:http://6mz.cn/article/heisje.html

其他资讯