dongqu4443 2018-01-28 15: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 16: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"].

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

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化