1
好的,我正在爲這個問題瘋狂,我無法獲得此表單提交,它只是刷新頁面。Form拒絕在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。
任何幫助最讚賞:)
這個'<? echo form_open('quickcopy/edit /'.$ copy_details-> id); ''line'在'$ copy_details-> id'中返回所需的ID? –
您確定您的表單驗證如下: 'if($ this-> form_validation-> run()== FALSE) { \t $ this-> load-> view('myform'); } else { \t $ this-> load-> view('formsuccess'); }' –
@Vlakarados - 是的,它會得到正確的ID。 –