我似乎无法更新电话号码,我是 Codeigniter 的新手,并试图找出我做错了什么。
这是我的模型:
function updatePhone($submit_userid, $submit_phone) {
$this->db->where("intMemberID", $submit_userid);
$this->db->update("tblMembers", array(
"strPhoneNumber" => $submit_phone
));
}
这是我的控制器:
public function updateAccount() {
$this->load->model('updateModel');
$this->load->model('userModel');
$data['userdata'] = $this->session->userdata('userobject');
$this->form_validation->set_rules('phone', 'Phone', 'required|min_length[8]|max_length[12]|xss_clean');
if ($this->form_validation->run() == false) {
$this->load->view('updateView', $data);
} else {
$submit_userid = $this->input->post('userid');
$submit_phone = $this->input->post('phone');
$this->userModel->updatePhone($submit_userid, $submit_phone);
redirect('updateController/updateAccount');
}
}
这是我的观点:
<?php
echo validation_errors();
echo form_open('updateController/updateAccount');
echo '<input type="hidden" name="userid" value=' . $userdata->intMemberID . '/> <br/>';
echo "$userdata->strMemberFirstName $userdata->strMemberLastName";
echo "<br>";
echo "Phone Number: <input type='text' name='phone' placeholder='$userdata->strPhoneNumber'/>";
echo '<INPUT type="submit" value="Update" name="submit"/>';
echo form_close();
?>