Welcome Guest, Not a member yet? Register   Sign In
URL query string
#1

[eluser]chinedubond[/eluser]
Please i need some help.
How do i get the query string parameters from this URL

the controller is wizardcontroller
the method is processTransaction

I have not enabled querystring yet cos i am scared that if i do the other parts of my application that require URLs in the other format (controller/method/) might not work
this is the url below: i need to extract the follwoing parameters; txnref,rspdesc

http://www.getinsuredng.com/index.php/in...9/Nov/2008 08:26:36

i would appreciate ur help
#2

[eluser]xwero[/eluser]
You don't have to be scared that the 'normal' CI url structure breaks if you set the url_protocol in the config_url to PATH_INFO.

To get the values you want you can use $_GET[] or the CI alternative $this->input->get().
#3

[eluser]chinedubond[/eluser]
hello, i get a 404 error when i try it

404 Page Not Found

The page you requested was not found.
#4

[eluser]chinedubond[/eluser]
k fixed that 404 error.
Now the problem am getting is.

A PHP Error was encountered

Severity: Notice

Message: Undefined index: txnref

Filename: wizard/wizardcontroller.php

Line Number: 243
#5

[eluser]xwero[/eluser]
probably because you have a forward slash in the dtime value the function that CI sees is
Quote:processTransaction?txnref=8259575932734&mertid=GTB032123140500&rsp=W06&rspcode=W06&rspdesc;=(Error)&paytxncode;=&amt=5000000&fee=0&dtime=19
#6

[eluser]xwero[/eluser]
did you enable the query strings in the config file?
#7

[eluser]Teks[/eluser]
I'm a newbie in CodeIgniter, so please do cross-check my advice with other more experienced users.

[quote author="chinedubond" date="1227535943"]Please i need some help.
How do i get the query string parameters from this URL

[...]

http://www.getinsuredng.com/index.php/in...9/Nov/2008 08:26:36

i would appreciate ur help[/quote]

From the User Guide documentation - under the CodeIgniter URLs general section- it seems that if you wish to use query strings, your URLs must follow the following format:

http://www.mydomain.com/index.php?c=controller&m=method&arg1=optionalArgument1...

By default, you must use 'c=' in the query string to indicate the controller, and 'm=' to indicate the method. These can be changed in the site configuration file, if needed - see the directions in the User Guide documentation.

Please note, that your URL above does not seem to be properly formatted for the default CodeIgniter query strings to work. If you wished to use CLEAN URLs, however, your URL is not properly formatted, either. It seems to me, that you were trying to use a combination of query strings inside clean urls. I do not see why you would need to do that.

Let us suppose that in a controller named 'wizardcontroller' you have a processing method called 'processTransaction', and that method takes several arguments - such as 'txnref', 'mertid', 'rspcode', etc., as needed:

Code:
function processTransaction($txnref, $mertid, $rspcode)
{
  //your processing code goes here
}

If you wish to use query strings, your url would then be something like this:
http://www.getinsuredng.com/index.php?c=...spcode=W06

But it seems to me that query strings are not needed. You can just as easily have a CLEAN URL like this, which will work automatically for you:
http://www.getinsuredng.com/wizardcontro...140500/W06

Last of all, if you want to manually parse the URL - more work than you might need - you should read through the User Guide documentation on the URI Class. There are functions there that would enable you to do what you asked in the first place, such as $this->uri->uri_string() and $this->uri->segment_array().

I hope this helps.
#8

[eluser]chinedubond[/eluser]
It works now thanks a lot for your help




Theme © iAndrew 2016 - Forum software by © MyBB