首页 > 编程技术 > php

怎么防止刷新网页重复插入数据

发布时间:2016-11-25 17:41

关于怎么防止刷新网页重复插入数据方法很多也很简单的,下面我们就来提供几种参考的处理方法吧。

如何防止刷新网页插入数据
我做了一个留言板,但是每次刷新就会插入信息,请问怎么做才能防止刷新插入数据呢

JS每次操作后返回
$regs=mysql_query($shouruinsert,$conn);
if($regs) echo "<script>window.alert("操作成功");</script><font size=3><a href=inout.htm>你的收入已经入库,请返回.不要刷新本页以免重复提交</a></font><script>window.location.href='inout.htm';</script>";
}
else{
echo "<script>window.alert("操作失败");</script><font size=3><a href=inout.htm>请检查你提交的数据是否规范或者联系管理员!!</a></font>";}

可以在发表页生成个cookie,在提交页,如果提交成功了就把这个cookie清了,这个刷新的时候判断cookie是否存在就可以了

还有和种方法就是查询数据库之后直接判断,

if($regs){

die('is exisit');

}else{

mysql_.....

}

syntax error, unexpected T_CONCAT_EQUAL

Parse error: ,这个问题是我今天在写php程序时出现的一个简单的问题,其实这算不上什么问题,

下面我们来看看这段代码。

sql ="Select * from * where user_myid= '$uid' and user_type=0";
  $result = mysql_query( $sql ) ;
  if( mysql_num_rows( $result ) )
  {
   while( $rs = mysql_fetch_array( $result ) )
   {
    temp.= "<friend fid="".$rs[0]."" fname="".$rs[1]."" /> n";
   }
  }

哈哈,看到蓝色的temp栏目了没?

是前面少了一个$号,是不是不算问题呢,但是如何不仔细的话就是大问题哦。

 

我们来看看一个关于如何让fck能正常显示我们上传的图片吧。

<div id="wrapper">
<form name="form1" action="<?=$_SERVER["PHP_SELF"]?>" method="post">
标题:<input type="text" size="20" name="title" /><br />
<?php
include "fckeditor/fckeditor.php";    //包含文件
$ofckeditor = new FCKeditor("fckeditor1");  //创建实例
$ofckeditor->BasePath = "./fckeditor/";   //设置FCK的路径
$ofckeditor->ToolbarSet = "Default";    //设置编辑器工具栏类型
$ofckeditor->Width="700px";
$ofckeditor->Height = "300px";       //设置编辑器高度
$ofckeditor->Create();   //创建编辑器
?>
<br />
<input type="submit" name="submit" value="提交" />
</form>
<br />
</div>
<div>
<?php
  echo $_POST["fckeditor1"];
?>
</div>

路径不对。。
注意你的源代码:
<img" width=100% src="/fck/upload/image/20090406214620132.jpg" />
再看你的调用fck地址为:fckeditor/fckeditor.php
说明你的预览页面和fck不在同级。再说,FCK默认上传图片源代码里都应该是完整URL。
你的FCK似乎改动过吧。

配置一下你的fck就OK了。

如何扫描一个目录下的所有文件阿

将一个目录下面的所有的html列出来
当作连接显示

<?php
// Note that !== did not exist until 4.0.0-RC2

if ($handle = opendir('/path/to/files')) {
    echo "Directory handle: $handlen";
    echo "Files:n";

    /* This is the correct way to loop over the directory. */
    while (false !== ($file = readdir($handle))) {
        echo "$filen";
    }

    /* This is the WRONG way to loop over the directory. */
    while ($file = readdir($handle)) {
        echo "$filen";
    }

    closedir($handle);
}
?>

Warning: session_start(): Cannot send session

cache limiter

echo "<a href='../home.php'>Home</a>n<br />";
session_start();

cache limiter

想知道为什么session_start();加一句就会出现警告消息

session_start(): 放在文件开始  试试

Note: If you are using cookie-based sessions, you must call session_start() before anything is outputted to the browser.

如果你正在使用基于cookie的sessions,不要在session_start前面输出任何东西都浏览器
标签:[!--infotagslink--]

您可能感兴趣的文章: