Welcome Guest, Not a member yet? Register   Sign In
Passing a variable value from View to Controller
#1

[eluser]alvaroeesti[/eluser]

Yes, that is the question, how do you do it without doing anything? I mean, without putting that in a form and clicking on a submit button.

That is, if you want to pick the IP of your visitors, it has to be on the View, then that value would have to be sent to the controller and from the controller to the Model.

If I could pick the IP at the controller that would be no problem, but it doesn't pick it up.

So, up to now, when I wanted to send a value from the View to the controller it was by means either a form and a click button, or in a link and anchor but this has to be automatically without user intervention.

I would be thinking of putting it in an Onload event in a javascript, when the page loads, you get the IP and send it to a controller? and how if you are not clicking neither buttons nor links, does it really have to be that way?
#2

[eluser]apodner[/eluser]
Remember that index.php is a front controller. That is the script that every user interacts with on every HTTP request.

That said, what are you doing in the controller presently to try and get the ip address which is not working?

What is the output of the following (paste it into your controller method):
Code:
echo '<pre>'. print_r($this->input->ip_address(), true) . '</pre>';


#3

[eluser]Aken[/eluser]
The IP address is certainly available to your controller: $_SERVER['REMOTE_ADDR'] (edit: apodner's suggestion of the Input library does add more logic, and might work better for you). You're thinking of a Javascript solution, which is not possible to pass back to the controller unless you want to get into ajax requests and that sort of thing.
#4

[eluser]alvaroeesti[/eluser]
yes, it is true, it did echo the remote address at the controller

After solving an additional bug that I had, it worked.

Thank you everybody




Theme © iAndrew 2016 - Forum software by © MyBB