Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Using query strings and uri segments in the same CI app
#1

[eluser]mradlmaier[/eluser]
Hi All.

I am not sure, if I understand the documentation right. Maybe someone can enlighten me:

I have the following situation: I have a CI application, happily using Uri segments.
But there is a third party application, which will need access with query strings somehow like this:

http://myapp.com/ci/login_chat.php?usern...ssword=def

I am at a loss, how to do that.
I have seen, that it is possible to enable query strings in the config.php.
But a lot of question come to my mind:
1-WIll "login_chat.php" be a controller?
2-If so, will the method call be to index() ?
3-How would i access the query parameters inside index()?
4-In all other controllers, i still need to use Uri segments (CI style). Is this possible or will enabling query strings, force Me to abandoner Uri segments?
5-Do I need to add ? & = to the permitted Uri chars?

Thanks for any help
Best regards,
Michael


EDIT:
http://ellislab.com/forums/viewthread/99570/
this help me solve the issue:
My config.php:
Code:
$config['uri_protocol']    = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
Now I have a controller login_chat.php looking like this:
Code:
<?php
class Login_chat extends Controller {  
    function Login_chat()
    {  
        parent::Controller();
    }  
    
    function process_login()
    {
        $data = array();
        $data['username'] = $_GET['username'];
        $data['password'] = $_GET['password'];
        $this->load->view('login_chat_view', $data);
    }
}
?>

with a view like this:

Code:
<?php
echo "Username: " . $username . "<br />";
echo "Password: " . $password . "<br />";
?&gt;

which i access like this:

http://127.0.0.1/ci3/login_chat/process_...ssword=def

and output is this:

Quote:Username: abc
Password: def
As one can see, this enables access to query strings. At the same time the CI style (example.com/news/article/my_article) in the rest of the CI app nicely coexists.
Actually in typical CI manner pretty simple and cool ;-)

Best regards,
Michael




Theme © iAndrew 2016 - Forum software by © MyBB