简体   繁体   English

将数据上传到数据库时出现问题

[英]Issue with uploading data into database

I am facing problem in sending data to database. 我在将数据发送到数据库时遇到问题。 The problem is every time i refresh the page it automatically send the previous data. 问题是每次我刷新页面时它都会自动发送以前的数据。 Can any one help. 谁能帮忙。

if (isset($_POST['Posts'])) {
    if (isset($_POST['t']) && isset($_POST['i']) && isset($_POST['P'])) {
        $title = $_POST['t'];
        $idea = $_POST['i'];

        if (!empty($title) && !empty($idea)) {
            $query = "INSERT INTO `updates` VALUES ('".mysql_real_escape_string($title)."')";
            if ($query_run = mysql_query($query)) { } 
            else {
                echo 'Sorry ,we could\'t register you at this time.Try again later';
            } 
        }                    
    }
}

Clear your post data after insert in db. 插入db后清除您的帖子数据。 Add below code after insertion db code. 在插入db代码后添加以下代码。

$_POST = array();

like inside your if block 就像在你的if块里面

... 
 if ($query_run = mysql_query($query)) { $_POST = array(); } 
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM