问题:当我提交一次留言后,参数就被记录在receive.php页面的地址栏里了,所以,如果刷新receive.php页面的话就会把先前提交的那个信息又显示一遍
解决:
法1,表单数据提交后即进行页面跳转:
具体如下:
数据库文件:
1
create
table
form(
2 name char ( 50 ) not null
3 );
2 name char ( 50 ) not null
3 );
表单文件一form.php
1
<
form action
=
"
form_handle.php
"
method
=
"
post
"
>
2 < input type = " name " name = " name " />< input type = " submit " value = " submit " >
3 </ form >
2 < input type = " name " name = " name " />< input type = " submit " value = " submit " >
3 </ form >
表单处理文件:form_handle.php
1
<?
php
2 if ( isset ( $_POST [ ' name ' ])){
3 $link = mysql_connect ( ' localhost ' , ' root ' , '' );
4 mysql_select_db ( ' test ' );
5 mysql_query ( " insert into form(name) values('{ $_POST ['name']}') " );
6 mysql_close ( $link );
7
8 }
9
10 header ( ' Location:form.php ' );
11
12 ?>
2 if ( isset ( $_POST [ ' name ' ])){
3 $link = mysql_connect ( ' localhost ' , ' root ' , '' );
4 mysql_select_db ( ' test ' );
5 mysql_query ( " insert into form(name) values('{ $_POST ['name']}') " );
6 mysql_close ( $link );
7
8 }
9
10 header ( ' Location:form.php ' );
11
12 ?>
另外可以做成,表单提交成功后,跳转到一个提示页,这个提示页几秒钟后自己跳转到另外一个页面。很多网站是这样做的,呵呵!,
当然这只是解决问题的一种方法,还有很多其它方法,有兴趣的可以尝试下。