Codeigniter update function doesn't work corectly -
I have a problem with the update function. This code is updating all the rows in the database and I want to update only the line with the login username. "Password" is one I have logged in and I have to replace it with password 3. The problem is that the password replaces all the rows (the password) in my database.
function edit_member () {$ new_member_update_data = array ('password' = & gt; md5 ($ this-> input- & gt; post ('password3')); $ This- & gt; Db- & gt; Where ('password', $ this-> input- & gt; post ('password')); $ Update = $ this- & gt; Db- & gt; Update ('subscription', $ new_member_update_data); Return $ update;
Assume that you have logged in So you get the userId from Sessions ..? Then use it as the function edit_member () {$ new_member_update_data = array ('password' = & gt; MD5 ($ this-> Input-> Post (' Password3 '))); $ This- & gt; Db- & gt; Where ('iUserId', $ this-> session-> userdata ('iUserId')); $ Update = $ this- & gt; Db- & gt; Update ('subscription', $ new_member_update_data); Return $ update; } Please consider that iUserId will be the area which is unique or auto increment field.
Comments
Post a Comment