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

网站建设知识

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

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

php获取不到表单数据 php获取不到表单数据的原因

PHP表单提交后无法获得数据

你访问的是文件路径,并不是服务地址;

创新互联是一家专注于成都网站制作、成都网站设计与策划设计,修文网站建设哪家好?创新互联做网站,专注于网站建设十年,网设计领域的专业建站公司;建站业务涵盖:修文等地区。修文做网站价格咨询:18982081108

你访问Localhost或127.0.0.1,具体要看你指向的目录

php5.26下获取不到表单数据(获取内容为空)急求

我在我的本地测试了,可以得到

==============================

name.html

----------

html

head

titleadsf/title

/head

body

form action="hh.php" method="post"

Name: input type="text" name="name1" /

Age: input type="text" name="age" /

input type="submit" /

/form

/body

/html

===================================

hh.php

-----------

html

head

titleadsf/title

/head

body

Welcome ?php

echo $_POST["name1"];?.br /

You are ?php echo $_POST["age"];? years old.

/body

/html

**********************************************

输入:

| 名字:asdfadff

| 年龄:13

--------------------------------------------

--------------------------------------------

结果:

Welcome asdfadff.

You are 13 years old.

******************************************************************

我觉的即使你那样解决了,也不是问题的根本

因为我这里能够测试成功,说明那个是没有问题的

还有,你可以试试把HTML格式写全

php post 为何无法获取表单值?

后台获取前端表单的值,依赖于表单控件的name属性,而 INPUT id="token" VALUE ="证明材料" 并没有设定name属性,所以获取不到,应该改为 INPUT name="token" id="token" VALUE ="证明材料"

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"urlheader:{$header}br":

8、echo"urlbody:$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、functionget_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、returnfalse;

10、}else{

11、$request="GET$queryHTTP/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、functionGetUrlHTML($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、 returnfalse;

35、}

36、?

参考资料:

php-file_get_contents

PHP获取表单,不能获取

?

echo $_POST['textfield'];

?

因为服务器禁止了全局自动变量。获取表单得用$_POST或者$_GET

php找不到表单的值?这是为什么?

我测试了下代码

首先 PHP 没有now()这个函数

第二 'null', '.$title.', '.$keywords.', '.$author.', '.$content.',$addtime)"; 这些变量前面后面的点都是做什么的?

把now()函数去掉可以正常插入数据库 就是每条数据前后都带“.”

修改后代码

?php

$con = mysql_connect("localhost","root","1") or die( " xxxxx");

mysql_select_db("newsdb",$con);

$id = $_POST[id];

$title = $_POST[title];

$keywords = $_POST[keywords];

$author = $_POST[author];

$content = $_POST[content];

$sql = "INSERT INTO `newsdb`.`news` (`id`, `title`, `keywords`, `author`, `content`, `addtime`) VALUES ('null', '$title', '$keywords', '$author', '$content',now())";

if(mysql_query($sql,$con))

{

echo "ok,the data is ok!";

}

?


新闻名称:php获取不到表单数据 php获取不到表单数据的原因
URL标题:http://6mz.cn/article/dooeseo.html

其他资讯