你是否遇到过“重复提交”的问题?要解决这个问题其实并不难。这里有一个简单的方法避免同一表单的重复提交。 首先,我们可以定义一个session变量用来保存一个表单的提交序列号。这里我定义为“$userLastAction”。然后在表单里加入一个hidden变量,把值设为$userLastAction+1: <input type=Hidden name=lastAction value=<? =$userLastAction+1 ?>> 最后,在处理提交之前判断表单是否已被提交过: if($lastAction>$userLastAction and inputIsValid(...)){ $userLastAction++; // 序列号加1 // 处理表单数据 } 原文: 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(...)){ 译自:phpbuilder |