表格拒绝在Codeigniter中提交

时间:2012-07-03 09:43:20

标签: php forms codeigniter

好的,我对此问题感到困惑,我无法提交此表单,只是刷新页面。

我编码与我网站上的其他表单完全相同,工作正常。我不明白为什么它没有提交!

这是控制器:

public function edit($id)
        {
            // check for login, if logged in
            if($this->session->userdata('logged_in') == "1")
                {
                // Check usertype, if not correct, redirect
                if($this->session->userdata('usertype') == "0" || $this->session->userdata('usertype') == "1" || $this->session->userdata('usertype') == "2")
                    {
                        // if no photos are selected, redirect and show notification
                        $this->session->set_flashdata('notification_fail', '<p style="text-align:center; color:#fbfbfb;">You do not have permission to access that page!<p>');
                        redirect('/');
                    }
                else 
                    {
                        // get the copy details
                        $data['copy_details'] = $this->quickcopy_model->get_copy_details($id);


                        if ($_POST)
                            {
                                // get data from the submitted form
                                $title = $this->input->post('title', TRUE);
                                $copy = $this->input->post('copy', TRUE);

                                // update the row in the db
                                $this->quickcopy_model->edit_go($id, $title, $copy);

                                // redirect and show notification
                                $this->session->set_flashdata('notification', '<p style="text-align:center; color:#fbfbfb;">That copy was updated!<p>');
                                redirect('quick-copy');
                                die;
                            }

                        // load views
                        $this->load->view('templates/header', $data);
                        $this->load->view('quickcopy/quickcopy_edit', $data);
                        $this->load->view('templates/footer', $data);
                    }
                }
            else
                {
                    // redirect to signin page if not logged in
                    redirect('signin');
                }
        }

从模型中调用函数:

public function edit_go($id, $title, $copy)
        {
            $data = array(
                   'title' => $title,
                   'copy' => $copy
                );

            $this->db->where('id', $id);
            return $this->db->update('quickcopy', $data); 
        }

最后是观点:

<? echo form_open('quickcopy/edit/'.$copy_details->id); ?>
<p>Title/tagline:</p>
<input type="text" class="Form_Input" id="title" name="title" value="<? echo $copy_details->title; ?>" />

<p style="margin-top: 10px;">Copy:</p>
<textarea id="copy" name="copy" class="Form_Textarea" style="width: 970px"><? echo $copy_details->title; ?></textarea>


<button type="submit" class="Form_SubmitButton"><p style="color: #f7f7f7; text-align: center;">Save changes</p></button>
</form>

我意识到我没有对此进行表单验证,但是我有另一种形式,我已经使用了表单验证,它也无法正常工作!

对此已经完全困惑了2天,我不知道为什么它没有提交。代码对我来说都很好看,还有什么其他原因可以让表单不提交?我刚安装了一个SSL,但我有其他形式工作正常,所以我假设它不是SSL。

非常感谢任何帮助:)

1 个答案:

答案 0 :(得分:1)

好的,我已经设法弄清楚问题是什么......最后!

基本上我有一些受SSL保护的网站部分而其他部分则没有。我忘了将新表单部分添加到htaccess文件中的SSL中。

立即工作。