all db records get updated instead of only 1 |
Hu guys, I am working on a school project.
I have a validateUser function in my Users.php controller: PHP Code: public function validateUser() This is my validateUser function in my UserModel.php PHP Code: public static function validateUser($id_user) My view Code: <div class="container"> Any idea what I'm doing wrong ? I read the CI4 documentation on db updates...
(01-05-2021, 10:28 AM)iRedds Wrote: Use getGet() instead getPost() That did the trick. Thanks ! I think I understand why it didn't work before: because my view page sends the parameter 'id_user' via the GET method. Is this correct ? Could I force my view to send the parameter via POST instead of GET ? I want to try to juggle with the methods now so that I get a better grasp. Thanks again !
Also your update is backwards.
PHP Code: $model->update($id_user,$data); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(01-05-2021, 12:30 PM)InsiteFX Wrote: Also your update is backwards. I found this in the documentation https://codeigniter.com/user_guide/model...aving-data PHP Code: $data = [ And my code also works in this fashion. If I reverse the parameters like you said I get an error. (01-05-2021, 10:36 AM)[email protected] Wrote:(01-05-2021, 10:28 AM)iRedds Wrote: Use getGet() instead getPost() Yes you are right. All data sent in url like ?кey=value are placed in the $_GET array. There is no easy way to send data using the $_POST method (at least I don't know about that). Or use a form to submit data or AJAX. In this way, you can specify the method for sending data.
(01-06-2021, 04:10 AM)iRedds Wrote:(01-05-2021, 10:36 AM)[email protected] Wrote:(01-05-2021, 10:28 AM)iRedds Wrote: Use getGet() instead getPost() Thanks for the help, much appreciated ! Alex |
Welcome Guest, Not a member yet? Register Sign In |