Welcome Guest, Not a member yet? Register   Sign In
Problem: Passing value in URL query string
#1

[eluser]carvingCode[/eluser]
How do I send data to a control function from the URL?

I want to send 1 piece of data to a function, telling it that it is being run remotely. The function then will do it's thing, but not write output to browser or change views as it does when run from a menu.

In my tests, I've placed '?remote=TRUE' in the URL.

Code:
a href=\"".base_url()."upload_ctrl/get_daily_update_file?remote=TRUE\">Process daily file</a>

This has created a '404 Page Not Found' error. (Link without '?remote=TRUE' works fine.) My function contains a statement to grab the $_POST value:

Code:
$remote = $_POST['remote'];

And the function is set to receive the value:

Code:
function get_daily_update_file($remote = FALSE)

Any help greatly appreciated. (I have searched the docs, but couldn't find a proper solution.)

TIA
#2

[eluser]danmontgomery[/eluser]
You need to enable query strings and change the value of uri_protocol in config.php.

http://www.askaboutphp.com/58/codeignite...rings.html
#3

[eluser]erik.brannstrom[/eluser]
Actually, by using the url upload_ctrl/get_daily_update_file/true your controller method already has the value in the variable $remote. If you method has got parameters, the URI segments after the method name will be stored in these automatically.
#4

[eluser]carvingCode[/eluser]
[quote author="erik.brannstrom" date="1273008723"]Actually, by using the url upload_ctrl/get_daily_update_file/true your controller method already has the value in the variable $remote. If you method has got parameters, the URI segments after the method name will be stored in these automatically.[/quote]

Thanks. Yes, indeed. This works fine.




Theme © iAndrew 2016 - Forum software by © MyBB