好的,我对这个问题发疯了,我无法提交此表单,它只会刷新页面。
我已经将它编码为与我网站上的其他表单完全相同,它们工作正常。我不明白为什么它不提交!
这是控制器:
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。
非常感谢任何帮助:)