Welcome Guest, Not a member yet? Register   Sign In
Passing $Data to the Controller from View?
#1

[eluser]thesocialhacker[/eluser]
Let's say i want to pass some data from the view back to the controller.
how is this done, in the CodeIgniter way?
#2

[eluser]thesocialhacker[/eluser]
any other ways except uri-segment(3)?
i'd rather not have this exploitable by user?
#3

[eluser]mddd[/eluser]
You shouldn't think of "sending from Controller to View". You probably mean sending information while requesting a new web page.
You could do this through the url (www.example.com/controller/method/argument) or using a form to POST information to the page.
In both occasions, there is no certainty of what a user can send. You must always check if the user's input is safe to use.
#4

[eluser]natefons[/eluser]
the safest way i can think of, would be to pass it in a hidden POST.
#5

[eluser]basementDUDE[/eluser]
if you just a need a product ID(small data) number, pass it thought URI.
if you need a comments(large data) from user then you have to make a forum in the view and post it to the controller.
#6

[eluser]InsiteFX[/eluser]
There is a third parameter to the view!

Code:
Returning views as data
There is a third optional parameter lets you change the behavior of the function
so that it returns data as a string rather than sending it to your browser.
This can be useful if you want to process the data in some way. If you set the
parameter to true (boolean) it will return data. The default behavior is false,
which sends it to your browser. Remember to assign it to a variable if you want
the data returned:

$string = $this->load->view('myfile', '', true);

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB