Welcome Guest, Not a member yet? Register   Sign In
How do you prefer passing on ID from view to controller when editing data?
#1

[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! Smile
#2

[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.
#3

[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.
#4

[eluser]InsiteFX[/eluser]
I use anchor tags, edit delete etc.

InsiteFX
#5

[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.




Theme © iAndrew 2016 - Forum software by © MyBB