dongqu4443 2018-01-28 07:54
浏览 261
已采纳

CodeIgniter没有对帖子做出反应

When I submit a form for the url example.com/index.php/topic/1/test-topic-test CodeIgniter does not recognize that a post form is submitted.

Routes:

$route["topic/(:num)/([a-z]+)"]["post"] = "forums/topic_post_reply/$1/$2";

Forums.php controller:

    public function topic_post_reply($id, $name)
    {
        $message = $this->input->post("topic_reply_content");
        if(!empty($message) && !empty($this->session->userdata('id')))
        {
            $data = [
                "content" => $message,
                "author" => $this->session->userdata('id'),
                "reply_date" => time(),
                "parent" => $id
            ];

            $this->db->insert("forum_topics_replies", $data);
        }
        else
        {
            die("Something went wrong");
        }
    }

Form:

<form class="uk-form-stacked" action="<?php echo base_url(); ?>index.php/topic/<?php echo $this->uri->segment(2); ?>/<?php echo $this->forums_model->slug($this->uri->segment(3)); ?>" method="post">
<div class="uk-form-inline">
    <textarea class="uk-textarea" name="topic_reply_content" rows="4" placeholder="Write a lovely reply..."></textarea>
</div>

<div class="laevis-reply-hidden">
    <div class="uk-margin-small" style="margin-bottom:0">
        <input type="submit" class="uk-button uk-button-primary uk-width-1-1" value="Post">
    </div>
</div>

Why isn't this working?

展开全部

  • 写回答

1条回答 默认 最新

  • doulouli8686 2018-01-28 08:38
    关注

    I had to have the post route above all other routes for the same url or it would not work. I also had to change it to $route["topic/(:num)/:any"]["post"].

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部