How do you prefer passing on ID from view to controller when editing data? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How do you prefer passing on ID from view to controller when editing data? (/showthread.php?tid=42740) |
How do you prefer passing on ID from view to controller when editing data? - El Forum - 06-17-2011 [eluser]donald.tbd[/eluser] So far i have used two ways to pass on ID from view to controller when editing a row. 1) On url row, for example form action = "news/edit/7", accessible in controller by $this->uri->segment(3). 2) Hidden field in form. For example <input type='hidden' name='id' value='7'>, accessible in controller by $this->input->post("id"). Witch one do you usually use? What are the pros/cons of each? Witch one is the the "right" or at least better way to do it. Thank you! How do you prefer passing on ID from view to controller when editing data? - El Forum - 06-17-2011 [eluser]Seb[/eluser] I would put the ID on url line if it is public and not changing, and when I want people to bookmark easily th pages. On the other way, when the IDs are totally meaningless and/or can be changed over time, or when I don't want people to mess with them, I put them into form inputs. How do you prefer passing on ID from view to controller when editing data? - El Forum - 06-17-2011 [eluser]n0xie[/eluser] They have different functions. GET requests a resource. The 'id' part of the url tells the webserver what resource it want. POST is used to pass 'form' data to the webserver. I.e. I want to submit something and it has to be linked to this id. How do you prefer passing on ID from view to controller when editing data? - El Forum - 06-17-2011 [eluser]InsiteFX[/eluser] I use anchor tags, edit delete etc. InsiteFX How do you prefer passing on ID from view to controller when editing data? - El Forum - 06-18-2011 [eluser]Nick_MyShuitings[/eluser] Given that this is mostly an issue for people with permissions who've been authenticated... I'm not so worried about the url structure for them... plus most sites have hideous urls compared to mine. But, I use both, I do the form hidden and the get url. I then check to make sure that they match, so that nobody can copy and edit/7 url and then paste it. |