Reputation: 3055
Im trying to write a function to update password with codeigniter and here is the code
public function changepass(){
$password = md5( $this->_clean($_POST['Password']) );
$data = array(
'Password' => $password
);
$this->db->update('users', $data, array('UserName' => $_POST[UserName]));
}
this updates the database but still throwing a message
Severity: Notice
Message: Use of undefined constant UserName - assumed 'UserName'
how to prevent this message and also how to check whether query executes successfully or not and echo a message "success" in this case?
Upvotes: 0
Views: 198
Reputation: 552
Change $_POST[UserName]
to $this->input->post('UserName')
as long as you are in controller. This does not work in model. CodeIgniter also destroys $_POST array.
$this->db->affected_rows()
should return 1 for success.
Upvotes: 5