资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

php搜索返回数据的表单 php查询表单

php如何实现点击浏览器的返回上一页(后退)按钮后还回到表单提交页面

表单的是位于form标签中action为地址跳转。也就相当于一次访问被存入历史记录;

成都创新互联一直在为企业提供服务,多年的磨炼,使我们在创意设计,成都全网营销到技术研发拥有了开发经验。我们擅长倾听企业需求,挖掘用户对产品需求服务价值,为企业制作有用的创意设计体验。核心团队拥有超过10余年以上行业经验,涵盖创意,策化,开发等专业领域,公司涉及领域有基础互联网服务多线BGP机房、app软件定制开发、手机移动建站、网页设计、网络整合营销。

假设浏览器没有这个机制,你买了个东西表单提交之后再返回到上一页表单又被提交了一次,那是到底买一个商品还是两个商品呢?用户可不懂这是什么意思,在后台你只会看到该用户下了两个订单;

解决办法:

使用异步提交表单即可。ajax提交表单,并且可以不跳转验证该表单的合法性、用户体验也能够提高。

请问PHP服务器端表单验证不通过时,如何将用户数据再返回到表单?

css:

style

input,textarea {behavior:url(#default#savehistory);} //这个css属性,他会记录历史输入内容,即使跳转也不会清除内容的。注:这里是所有input和textarea,具体你可以根据需要修改。type=password的不会记录。

/style

这样,你就可以随意跳转了,你只需要输出错误信息就好了。

php如何在一个页面从数据库返回数据到原表单的文本框里

一般这个页面要有get传值,后台只有接收到这个get值才能判断到底取哪条数据放到文本框中。

一般根据id,从数据库选出数据,最后再放到页面上就行。

其实就是一般理解的 “编辑”,对原有数据的修改。

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搜索查询数据库数据

查看一下代码:

?php

// 获取表单提交值

$student_id = intval(trim($_POST['student_id']));

// 页面表单  可以放单独的html文件中,如果放单独的html页面中 form 的action的地址要改成下面的PHP文件名

echo 'form action="" method="post"

input type="text" name="student_id" value="{$student_id}"/

input type="submit" name="submit" value="查询"/

/form';

// 当有数据提交时

if ($student_id)

{

$con= mysql_connect("localhost","root","111") or die("连接错误");

mysql_select_db("examination",$con);

// 查询

$sql = "SELECT * FROM tablename WHERE student_id = $student_id ";

$res=mysql_query($sql);

$row=mysql_fetch_array($res);

// 输出

echo '学号:'.$row['student_id'].'br姓名:'.$row['name'].'br性别:'.$row['gender'].'br分数:'.$row['score'];

}

?


当前名称:php搜索返回数据的表单 php查询表单
URL分享:http://cdkjz.cn/article/hjppep.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220