就象csdn这样,你在添加数据的同时也看到我的发言,只是我把数据的
处理程序也放在这一页,我的程序格式是这样的
 if($action=="send")
{//向数据库中添加数据}显示数据程序添加数据界面

解决方案 »

  1.   

    看这个把:如何避免表单的重复提交
    2002-5-30  视点网络工作室 
     
    你是否遇到过“重复提交”的问题?要解决这个问题其实并不难。这里有一个简单的方法避免同一表单的重复提交。 
    首先,我们可以定义一个session变量用来保存一个表单的提交序列号。这里我定义为“$userLastAction”。然后在表单里加入一个hidden变量,把值设为$userLastAction+1: 
    <input type=Hidden name=lastAction value=<? =$userLastAction+1 ?>> 
    最后,在处理提交之前判断表单是否已被提交过: 
    if($lastAction>$userLastAction and inputIsValid(...)){ 
    $userLastAction++; // 序列号加1 
    // 处理表单数据 
    } 原文: 
    Avoid multiple form submissions 
    Submitted By: Douglas E. Cook 
    Date: 07/26/00 19:46 
    Does your database suffer from "duplicate post" syndrome? The cure isn't too difficult. Here is a simple way to prevent users from submitting the same form multiple times. First, declare a session variable to store a serial number for each form. I call mine "$userLastAction." Then, in every form where duplicate submission is a problem, include a hidden field, and set the value to $userLastAction+1: <INPUT TYPE=HIDDEN NAME=lastAction VALUE=<?= $userLastAction+1 ?>> Finally, verify that the form has not been previously submitted before acting on the submission: if($lastAction>$userLastAction and inputIsValid(...)){ 
    $userLastAction++; // Increment serial number 
    // Act on form here 
    } 译自:phpbuilder 
      

  2.   

    一个郁闷问题
    我的一个留言板程序如果把添加留言界面,显示留言界面,处理留言程序都放在
    同一个页面中text.php
    就出了一个问题
    用户添加完留言后,按刷新程序就不断的把刚才的输入数据再添加到数据库中
    再显示出来,也就是用户输入一次,然后按刷新十次它就相当于用户输入十次
    该怎么改掉这个bug???
    你可以在处理留言完毕后输出一个 javascript的网页转向语句就停下来<?php
    if($_POST['op']=="add")
      {
       //处理留言操作
       ....   
       echo   ("<script type=\"test/javascript\">location='main.php';</script>");
       exit;
    }
    ?>
      显示留言网页