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?