新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

php获取另一个表单数据 php获取另一个php返回内容

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

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

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

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 如何从一个表里连接查询出另一个表内的数据

//A表m的值

$m = 1;

$result = mysql_query("select n from B where x in(select x from A where m={$m})");

$rs = mysql_fetch_assoc($result);

$n = $rs['n'];

//B表n的值

echo $n;

表单提交到另一个php页面,如何保存获取表单值

一个表单无法同时提交多个页面,只有提交给一个页面后,再提交给下一个页面,就象安装软件时候的“下一步”一样,是一步一步的传递的。

php文件获取“上一步”表单传递来的数据,方法是使用数组$_get和$_post,例如表单里面有inputtype=textname=uservalue=abc,那么在php里面就有$_get["user"]或者$_post["user"](根据表单的提交方法),其值为"abc"。

php数据为空读取另一张表

$query = $this-db-get('Table1')-result(); // get first table

foreach($query as $result)

{

//Your Post Values from form data in array : POST_DATA

$post_data = array_from_post('filed1,filed2....');

$data = array_merge($result,$post_data);

$this-db-insert('Table2', $data); // insert each row to another table

}

在这里我已经在我的基础模型中定义了array_from_post,您可以像这样使用它:

public function array_from_post($fields){

$data = array();

foreach ($fields as $field) {

$data[$field] = $this-input-post($field);

}

return $data;


文章名称:php获取另一个表单数据 php获取另一个php返回内容
标题网址:http://www.wjwzjz.com/article/hioijj.html
在线咨询
服务热线
服务热线:028-86922220
TOP