标题和重定向在PHP中

时间:2017-07-17 06:28:25

标签: php html

我的问题是在我的添加帖子页面,当我提交重定向未完成而header()似乎无法正常工作

        public function insert($query){
        $insertRecord = $this->link->query($query) or die($this->link->error.__LINE__);
        if($insertRecord){
            header("Location:admin/index.php?msg=".urlencode('Record Added'));
            exit();
        }  else {
            die("Error : (".$this->link->errno.')'.$this->link->error);
        }
    }

        if($title == "" || $body == "" || $category == "" || $author == ""){
        $error = "please fill all required fields";
    }  else {
        $query = "insert into posts(category,title,body,author,tags) values ('$category','$title','$body','$author','$tags')";
        $insertRecord = $db->insert($query);
    }

1 个答案:

答案 0 :(得分:0)

header('Location: admin/index.php?msg='.urlencode('Record Added'));